version 1.5.20.6, 2018/01/01 23:48:32
|
version 1.5.20.9, 2018/01/02 02:02:16
|
Line 48 SUCH DAMAGE.
|
Line 48 SUCH DAMAGE.
|
|
|
cfg_root_t cfg; |
cfg_root_t cfg; |
int Verbose, Timeout, kq; |
int Verbose, Timeout, kq; |
ait_val_t User, Mount, Dev, Chroot; | ait_val_t User, Mount, Chroot; |
char szSess[MAXPATHLEN], szSLCK[MAXPATHLEN], szConfig[MAXPATHLEN]; |
char szSess[MAXPATHLEN], szSLCK[MAXPATHLEN], szConfig[MAXPATHLEN]; |
extern char compiled[], compiledby[], compilehost[]; |
extern char compiled[], compiledby[], compilehost[]; |
|
|
Line 61 Usage()
|
Line 61 Usage()
|
"=== %s === %s@%s ===\n\n" |
"=== %s === %s@%s ===\n\n" |
" Syntax: cfexec [options] [exec_file]\n\n" |
" Syntax: cfexec [options] [exec_file]\n\n" |
"\t-v\t\tVerbose ...\n" |
"\t-v\t\tVerbose ...\n" |
|
"\t-C <config>\tLoad config [default=/etc/cfexec.conf]\n" |
"\t-c <dir>\tAfter execute chroot to dir [default=/]\n" |
"\t-c <dir>\tAfter execute chroot to dir [default=/]\n" |
"\t-u <user>\tAfter execute suid to user [default=root]\n" |
"\t-u <user>\tAfter execute suid to user [default=root]\n" |
"\t-d <dev>\tOther device [default=/dev/ufs/elwix]\n" |
|
"\t-m <mnt>\tOther mount dir [default=/]\n" |
"\t-m <mnt>\tOther mount dir [default=/]\n" |
"\t-t <sec>\tTimeout for autolock mount dir after seconds [default=300]\n" |
"\t-t <sec>\tTimeout for autolock mount dir after seconds [default=300]\n" |
"\t-L <reason>\tService lock and set RW state of device with reason\n" |
"\t-L <reason>\tService lock and set RW state of device with reason\n" |
Line 105 update(int flags)
|
Line 105 update(int flags)
|
return -1; |
return -1; |
} |
} |
|
|
VERB(5) printf("Info(5):: safe mount for device %s to %s operation (%s)\n", | VERB(5) printf("Info(5):: safe mount %s for device %s to %s operation (%s)\n", |
AIT_GET_STR(&Dev), AIT_GET_STR(&Mount), (flags & MNT_RDONLY) ? "ro" : "rw"); | mntfs->f_fstypename, mntfs->f_mntfromname, mntfs->f_mntonname, |
| (flags & MNT_RDONLY) ? "ro" : "rw"); |
return 0; |
return 0; |
} |
} |
|
|
Line 166 static void
|
Line 167 static void
|
cleanexit() |
cleanexit() |
{ |
{ |
AIT_FREE_VAL(&User); |
AIT_FREE_VAL(&User); |
AIT_FREE_VAL(&Dev); |
|
AIT_FREE_VAL(&Mount); |
AIT_FREE_VAL(&Mount); |
AIT_FREE_VAL(&Chroot); |
AIT_FREE_VAL(&Chroot); |
|
|
cfgUnloadConfig(&cfg); |
|
} |
} |
|
|
static int |
static int |
Line 246 main(int argc, char **argv)
|
Line 244 main(int argc, char **argv)
|
} |
} |
cfg_loadAttribute(&cfg, "cfexec", "suid", &User, DEFAULT_USER); |
cfg_loadAttribute(&cfg, "cfexec", "suid", &User, DEFAULT_USER); |
cfg_loadAttribute(&cfg, "cfexec", "mount", &Mount, DEFAULT_MOUNT); |
cfg_loadAttribute(&cfg, "cfexec", "mount", &Mount, DEFAULT_MOUNT); |
cfg_loadAttribute(&cfg, "cfexec", "device", &Dev, DEFAULT_DEVICE); |
|
cfg_loadAttribute(&cfg, "cfexec", "chroot", &Chroot, DEFAULT_CHROOT); |
cfg_loadAttribute(&cfg, "cfexec", "chroot", &Chroot, DEFAULT_CHROOT); |
|
|
cfgUnloadConfig(&cfg); |
cfgUnloadConfig(&cfg); |
Line 254 main(int argc, char **argv)
|
Line 251 main(int argc, char **argv)
|
Timeout = atoi(DEFAULT_TIMEOUT); |
Timeout = atoi(DEFAULT_TIMEOUT); |
AIT_SET_STR(&User, DEFAULT_USER); |
AIT_SET_STR(&User, DEFAULT_USER); |
AIT_SET_STR(&Mount, DEFAULT_MOUNT); |
AIT_SET_STR(&Mount, DEFAULT_MOUNT); |
AIT_SET_STR(&Dev, DEFAULT_DEVICE); |
|
AIT_SET_STR(&Chroot, DEFAULT_CHROOT); |
AIT_SET_STR(&Chroot, DEFAULT_CHROOT); |
} |
} |
|
|
atexit(cleanexit); |
atexit(cleanexit); |
|
|
/* Load variables from arguments if exists */ |
/* Load variables from arguments if exists */ |
while ((ch = getopt(argc, argv, "hvUu:c:d:m:t:L:")) != -1) | while ((ch = getopt(argc, argv, "hvUC:u:c:m:t:L:")) != -1) |
switch (ch) { |
switch (ch) { |
|
case 'C': |
|
if (!cfgLoadConfig(optarg, &cfg)) { |
|
cfg_loadAttribute(&cfg, "cfexec", "timeout", &User, DEFAULT_TIMEOUT); |
|
#ifndef HAVE_STRTONUM |
|
Timeout = (int) strtol(szUser, NULL, 0); |
|
#else |
|
Timeout = strtonum(AIT_GET_STR(&User), 0, 3600, &err); |
|
#endif |
|
AIT_FREE_VAL(&User); |
|
if (!Timeout && err) { |
|
printf("Error:: in seconds for timeout %s - %s\n", optarg, err); |
|
cfgUnloadConfig(&cfg); |
|
return 1; |
|
} |
|
cfg_loadAttribute(&cfg, "cfexec", "suid", &User, DEFAULT_USER); |
|
cfg_loadAttribute(&cfg, "cfexec", "mount", &Mount, DEFAULT_MOUNT); |
|
cfg_loadAttribute(&cfg, "cfexec", "chroot", &Chroot, DEFAULT_CHROOT); |
|
|
|
cfgUnloadConfig(&cfg); |
|
} |
|
break; |
case 'v': |
case 'v': |
Verbose++; |
Verbose++; |
break; |
break; |
Line 272 main(int argc, char **argv)
|
Line 289 main(int argc, char **argv)
|
case 'c': |
case 'c': |
AIT_SET_STR(&Chroot, optarg); |
AIT_SET_STR(&Chroot, optarg); |
break; |
break; |
case 'd': |
|
AIT_SET_STR(&Dev, optarg); |
|
break; |
|
case 'm': |
case 'm': |
AIT_SET_STR(&Mount, optarg); |
AIT_SET_STR(&Mount, optarg); |
break; |
break; |
Line 308 main(int argc, char **argv)
|
Line 322 main(int argc, char **argv)
|
memset(szSess, 0, MAXPATHLEN); |
memset(szSess, 0, MAXPATHLEN); |
snprintf(szSess, MAXPATHLEN, "%s%s-cfexec.LCK", DEFAULT_TMP, AIT_GET_STR(&Mount)); |
snprintf(szSess, MAXPATHLEN, "%s%s-cfexec.LCK", DEFAULT_TMP, AIT_GET_STR(&Mount)); |
memset(szSLCK, 0, MAXPATHLEN); |
memset(szSLCK, 0, MAXPATHLEN); |
snprintf(szSLCK, MAXPATHLEN, CFEXEC_SLOCK, DEFAULT_TMP); | snprintf(szSLCK, MAXPATHLEN, "%s%s-SYS-cfexec.LCK", DEFAULT_TMP, AIT_GET_STR(&Mount)); |
|
|
/* we have request for service lock! */ |
/* we have request for service lock! */ |
if (mod) { |
if (mod) { |
Line 320 main(int argc, char **argv)
|
Line 334 main(int argc, char **argv)
|
return ret; |
return ret; |
} |
} |
|
|
VERB(3) printf("Info(3):: Chroot=%s SUID=%s Device=%s Mount=%s Timeout=%d Session=%s\n", | VERB(3) printf("Info(3):: Chroot=%s SUID=%s Mount=%s Timeout=%d Session=%s\n", |
AIT_GET_STR(&Chroot), AIT_GET_STR(&User), AIT_GET_STR(&Dev), | AIT_GET_STR(&Chroot), AIT_GET_STR(&User), |
AIT_GET_STR(&Mount), Timeout, szSess); |
AIT_GET_STR(&Mount), Timeout, szSess); |
|
|
if (!access(szSess, F_OK)) { |
if (!access(szSess, F_OK)) { |