--- embedtools/src/cfexec.c 2018/01/02 01:46:03 1.5.20.8 +++ embedtools/src/cfexec.c 2018/01/02 02:02:16 1.5.20.9 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ - * $Id: cfexec.c,v 1.5.20.8 2018/01/02 01:46:03 misho Exp $ + * $Id: cfexec.c,v 1.5.20.9 2018/01/02 02:02:16 misho Exp $ * ************************************************************************* The ELWIX and AITNET software is distributed under the following @@ -61,6 +61,7 @@ Usage() "=== %s === %s@%s ===\n\n" " Syntax: cfexec [options] [exec_file]\n\n" "\t-v\t\tVerbose ...\n" + "\t-C \tLoad config [default=/etc/cfexec.conf]\n" "\t-c \tAfter execute chroot to dir [default=/]\n" "\t-u \tAfter execute suid to user [default=root]\n" "\t-m \tOther mount dir [default=/]\n" @@ -168,8 +169,6 @@ cleanexit() AIT_FREE_VAL(&User); AIT_FREE_VAL(&Mount); AIT_FREE_VAL(&Chroot); - - cfgUnloadConfig(&cfg); } static int @@ -258,8 +257,29 @@ main(int argc, char **argv) atexit(cleanexit); /* Load variables from arguments if exists */ - while ((ch = getopt(argc, argv, "hvUu:c:m:t:L:")) != -1) + while ((ch = getopt(argc, argv, "hvUC:u:c:m:t:L:")) != -1) 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': Verbose++; break;