--- src/ldso/dynlink.c.ori 2014-03-28 10:37:34.821317811 +0100 +++ src/ldso/dynlink.c 2014-03-28 16:45:26.435994022 +0100 @@ -1041,12 +1041,34 @@ size_t l = strlen(ldname); if (l >= 3 && !strcmp(ldname+l-3, "ldd")) ldd_mode = 1; *argv++ = (void *)-1; - if (argv[0] && !strcmp(argv[0], "--")) *argv++ = (void *)-1; + while (argv[0] && argv[0][0] == '-') { + if (argv[0][1] == '-' && argv[0][2] == 0) { /* "--" */ + *argv++ = (void *)-1; + break; + } + /* care about someone making the dynamic loader + * itself (!) setuid? (s)he has possibly good + * reasons, who am I to interfere -- thus + * no setuid checking here -- rl */ + if (!strcmp(argv[0], "--library-path")) { + *argv++ = (void *)-1; + env_path = argv[0]; /* even if NULL */ + } else if (!strcmp(argv[0], "--preload")) { + *argv++ = (void *)-1; + env_preload = argv[0]; /* even if NULL */ + } else + /* any - stops parsing */ + break; + if (!argv[0]) + /* missing argument? */ + break; + *argv++ = (void *)-1; + } if (!argv[0]) { dprintf(2, "musl libc\n" "Version %s\n" "Dynamic Program Loader\n" - "Usage: %s [--] pathname%s\n", + "Usage: %s [--library-path path] [--preload path] [--] pathname%s\n", __libc_get_version(), ldname, ldd_mode ? "" : " [args]"); _exit(1);