version 1.1.1.1.2.5, 2011/05/20 17:03:28
|
version 1.3, 2013/04/09 07:37:50
|
Line 53 initProg()
|
Line 53 initProg()
|
proc.proc_prio = getpriority(PRIO_PROCESS, 0); |
proc.proc_prio = getpriority(PRIO_PROCESS, 0); |
getcwd(proc.proc_dir, sizeof proc.proc_dir); |
getcwd(proc.proc_dir, sizeof proc.proc_dir); |
|
|
|
#if 0 |
lf = fopen(DEFAULT_LOG, "a"); |
lf = fopen(DEFAULT_LOG, "a"); |
if (!lf) |
if (!lf) |
|
#endif |
lf = stdout; |
lf = stdout; |
|
|
openlog(PACKAGE_NAME, LOG_CONS | LOG_PID | LOG_NDELAY | LOG_PERROR, LOG_USER); | openlog(PACKAGE_NAME, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER); |
} |
} |
|
|
static void |
static void |
Line 70 Usage()
|
Line 72 Usage()
|
"\t-g <group>\t\t\tGroup for suID\n" |
"\t-g <group>\t\t\tGroup for suID\n" |
"\t-p <priority (-20..20)>\t\tExecute with priority\n" |
"\t-p <priority (-20..20)>\t\tExecute with priority\n" |
"\t-d <directory>\t\t\tDirectory for suID\n" |
"\t-d <directory>\t\t\tDirectory for suID\n" |
|
"\t-C <directory>\t\t\tChroot to directory\n" |
|
"\t-c <cfgfile>\t\t\tConfig file\n" |
"\t-l <logfile>\t\t\tLog file path (default:/var/log/suX.log)\n" |
"\t-l <logfile>\t\t\tLog file path (default:/var/log/suX.log)\n" |
"\t-v\t\t\t\tVerbose, (more -v, more verbosity)\n" |
"\t-v\t\t\t\tVerbose, (more -v, more verbosity)\n" |
"\t-h\t\t\t\tThis help screen!\n\n", PACKAGE_NAME); |
"\t-h\t\t\t\tThis help screen!\n\n", PACKAGE_NAME); |
Line 226 Run(char **argv)
|
Line 230 Run(char **argv)
|
return -1; |
return -1; |
} |
} |
|
|
|
/* |
if (setgid(proc.proc_gid) == -1) { |
if (setgid(proc.proc_gid) == -1) { |
Err("Error:: setgid #%d - %s\n", errno, strerror(errno)); |
Err("Error:: setgid #%d - %s\n", errno, strerror(errno)); |
if (args) |
if (args) |
Line 244 Run(char **argv)
|
Line 249 Run(char **argv)
|
free(args); |
free(args); |
return -1; |
return -1; |
} |
} |
|
*/ |
|
|
Log(0, "UID:GID=%d:%d Prio=%d Class=%s Name=%s Dir=%s Cmd=%s", proc.proc_uid, proc.proc_gid, | Log(0, "UID:GID=%d:%d Prio=%d Class=%s Name=%s Dir=%s Cmd=%s Script=%s", |
proc.proc_prio, proc.proc_class, proc.proc_name, proc.proc_dir, proc.proc_cmd); | proc.proc_uid, proc.proc_gid, proc.proc_prio, proc.proc_class, |
| proc.proc_name, proc.proc_dir, proc.proc_cmd, getenv("PATH_TRANSLATED")); |
|
|
if (3 <= Verbose) { |
if (3 <= Verbose) { |
char **el = args - 1; |
char **el = args - 1; |
Line 267 Run(char **argv)
|
Line 274 Run(char **argv)
|
int |
int |
main(int argc, char **argv) |
main(int argc, char **argv) |
{ |
{ |
char ch, *str, szCfg[MAXPATHLEN], flg = 0; | char ch, *str, *wrk, szCfg[MAXPATHLEN], **pp, flg = 0; |
struct passwd *pass; |
struct passwd *pass; |
struct group *grp; |
struct group *grp; |
FILE *f; |
FILE *f; |
Line 275 main(int argc, char **argv)
|
Line 282 main(int argc, char **argv)
|
initProg(); |
initProg(); |
strlcpy(szCfg, DEFAULT_CONFIG, sizeof szCfg); |
strlcpy(szCfg, DEFAULT_CONFIG, sizeof szCfg); |
|
|
while ((ch = getopt(argc, argv, "hvc:u:g:p:d:l:")) != -1) | while ((ch = getopt(argc, argv, "hvC:c:u:g:p:d:l:")) != -1) |
switch (ch) { |
switch (ch) { |
case 'l': |
case 'l': |
f = fopen(optarg, "a"); |
f = fopen(optarg, "a"); |
Line 318 main(int argc, char **argv)
|
Line 325 main(int argc, char **argv)
|
case 'c': |
case 'c': |
strlcpy(szCfg, optarg, sizeof szCfg); |
strlcpy(szCfg, optarg, sizeof szCfg); |
break; |
break; |
|
case 'C': |
|
if (chroot(optarg) == -1) |
|
Err("Error:: chroot to dir"); |
|
if ((str = getenv("PATH_TRANSLATED"))) |
|
if ((wrk = strstr(str, optarg))) |
|
setenv("PATH_TRANSLATED", str + strlen(optarg), 42); |
|
break; |
case 'v': |
case 'v': |
Verbose++; |
Verbose++; |
break; |
break; |
Line 330 main(int argc, char **argv)
|
Line 344 main(int argc, char **argv)
|
} |
} |
argc -= optind; |
argc -= optind; |
argv += optind; |
argv += optind; |
|
|
|
if (2 <= Verbose) { |
|
for (pp = argv; *pp; pp++) |
|
Log(2, "Args=%s\n", *pp); |
|
for (pp = environ; *pp; pp++) |
|
Log(2, "Envs=%s\n", *pp); |
|
} |
|
|
if (!argc) { |
if (!argc) { |
if (!(str = getenv("PATH_TRANSLATED"))) { |
if (!(str = getenv("PATH_TRANSLATED"))) { |
Usage(); |
Usage(); |