version 1.1, 2009/11/12 10:35:55
|
version 1.2.2.1, 2011/06/13 20:04:12
|
Line 15 char szUser[MAX_STR], szMount[MAXPATHLEN], szDev[MAXPA
|
Line 15 char szUser[MAX_STR], szMount[MAXPATHLEN], szDev[MAXPA
|
szChroot[MAXPATHLEN], szSess[MAXPATHLEN], szConfig[MAXPATHLEN]; |
szChroot[MAXPATHLEN], szSess[MAXPATHLEN], szConfig[MAXPATHLEN]; |
extern char compiled[], compiledby[], compilehost[]; |
extern char compiled[], compiledby[], compilehost[]; |
|
|
|
|
static void Usage() |
static void Usage() |
{ |
{ |
|
|
Line 24 static void Usage()
|
Line 25 static void Usage()
|
"\t-v\t\tVerbose ...\n" |
"\t-v\t\tVerbose ...\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/AITBSDonCF]\n" | "\t-d <dev>\tOther device [default=/dev/ufs/elwix]\n" |
"\t-m <mnt>\tOther mount dir [default=/cf]\n" |
"\t-m <mnt>\tOther mount dir [default=/cf]\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" |
"\n", compiled, compiledby, compilehost); |
"\n", compiled, compiledby, compilehost); |
Line 36 static int update(int flags)
|
Line 37 static int update(int flags)
|
|
|
memset(&mnt, 0, sizeof mnt); |
memset(&mnt, 0, sizeof mnt); |
mnt.fspec = szDev; |
mnt.fspec = szDev; |
|
#ifdef __NetBSD__ |
|
if (mount("ufs", szMount, flags, &mnt, sizeof mnt) == -1) { |
|
#else |
if (mount("ufs", szMount, flags, &mnt) == -1) { |
if (mount("ufs", szMount, flags, &mnt) == -1) { |
|
#endif |
printf("Error:: can`t update mount %s #%d - %s\n", szMount, errno, strerror(errno)); |
printf("Error:: can`t update mount %s #%d - %s\n", szMount, errno, strerror(errno)); |
return -1; |
return -1; |
} |
} |
Line 87 static int mkevent(struct kevent *chg, struct kevent *
|
Line 92 static int mkevent(struct kevent *chg, struct kevent *
|
memset(chg, 0, sizeof(struct kevent)); |
memset(chg, 0, sizeof(struct kevent)); |
memset(evt, 0, sizeof(struct kevent)); |
memset(evt, 0, sizeof(struct kevent)); |
|
|
EV_SET(chg, f, EVFILT_VNODE, EV_ADD, NOTE_DELETE | NOTE_RENAME | NOTE_REVOKE, 0, NULL); | EV_SET(chg, f, EVFILT_VNODE, EV_ADD, NOTE_DELETE | NOTE_RENAME | NOTE_REVOKE, 0, (intptr_t) NULL); |
} |
} |
|
|
return f; |
return f; |
Line 98 static int mkevent(struct kevent *chg, struct kevent *
|
Line 103 static int mkevent(struct kevent *chg, struct kevent *
|
int main(int argc, char **argv) |
int main(int argc, char **argv) |
{ |
{ |
char ch; |
char ch; |
const char *err; | const char *err = NULL; |
struct kevent chg, evt; |
struct kevent chg, evt; |
struct timespec ts; |
struct timespec ts; |
pid_t pid; |
pid_t pid; |
Line 109 int main(int argc, char **argv)
|
Line 114 int main(int argc, char **argv)
|
// Load variables from config if exists |
// Load variables from config if exists |
if (!LoadConfig(szConfig, &cfg)) { |
if (!LoadConfig(szConfig, &cfg)) { |
cfg_LoadAttribute(&cfg, CFG("cfexec"), CFG("timeout"), CFG(szUser), MAX_STR, DEFAULT_TIMEOUT); |
cfg_LoadAttribute(&cfg, CFG("cfexec"), CFG("timeout"), CFG(szUser), MAX_STR, DEFAULT_TIMEOUT); |
Timeout = strtonum(szUser, 1, 3600, &err); | #ifndef HAVE_STRTONUM |
if (!Timeout) { | Timeout = (int) strtol(szUser, NULL, 0); |
| #else |
| Timeout = strtonum(szUser, 0, 3600, &err); |
| #endif |
| if (!Timeout && err) { |
printf("Error:: in seconds for timeout %s - %s\n", optarg, err); |
printf("Error:: in seconds for timeout %s - %s\n", optarg, err); |
UnloadConfig(&cfg); |
UnloadConfig(&cfg); |
return 1; |
return 1; |
Line 148 int main(int argc, char **argv)
|
Line 157 int main(int argc, char **argv)
|
strlcpy(szMount, optarg, MAXPATHLEN); |
strlcpy(szMount, optarg, MAXPATHLEN); |
break; |
break; |
case 't': |
case 't': |
Timeout = strtonum(optarg, 1, 3600, &err); | #ifndef HAVE_STRTONUM |
if (!Timeout) { | Timeout = (int) strtol(szUser, NULL, 0); |
| #else |
| Timeout = strtonum(optarg, 0, 3600, &err); |
| #endif |
| if (!Timeout && err) { |
printf("Error:: in seconds for timeout %s - %s\n", |
printf("Error:: in seconds for timeout %s - %s\n", |
optarg, err); |
optarg, err); |
return 1; |
return 1; |
Line 190 int main(int argc, char **argv)
|
Line 203 int main(int argc, char **argv)
|
if ((f = mkevent(&chg, &evt)) == -1) |
if ((f = mkevent(&chg, &evt)) == -1) |
return 5; |
return 5; |
|
|
memset(&ts, 0, sizeof ts); | if (Timeout) { |
ts.tv_sec = Timeout; | memset(&ts, 0, sizeof ts); |
switch (kevent(kq, &chg, 1, &evt, 1, &ts)) { | ts.tv_sec = Timeout; |
| } |
| switch (kevent(kq, &chg, 1, &evt, 1, !Timeout ? NULL : &ts)) { |
case -1: |
case -1: |
printf("Error:: can`t execute safe mount #%d - %s\n", |
printf("Error:: can`t execute safe mount #%d - %s\n", |
errno, strerror(errno)); |
errno, strerror(errno)); |
Line 236 int main(int argc, char **argv)
|
Line 251 int main(int argc, char **argv)
|
if (strncmp(szUser, "root", 5)) |
if (strncmp(szUser, "root", 5)) |
setuser(); |
setuser(); |
|
|
chdir("/"); | /* chdir("/"); */ |
execvp(*argv, argv); |
execvp(*argv, argv); |
} |
} |
_exit(127); |
_exit(127); |