version 1.5.20.2, 2017/10/08 21:58:47
|
version 1.5.20.3, 2017/10/08 22:28:26
|
Line 126 mkevent(struct kevent *chg, struct kevent *evt)
|
Line 126 mkevent(struct kevent *chg, struct kevent *evt)
|
} |
} |
VERB(3) printf("Created lock file %s\n", szSess); |
VERB(3) printf("Created lock file %s\n", szSess); |
|
|
kq = kqueue(); | if (chg && evt) { |
if (kq == -1) { | kq = kqueue(); |
printf("Error:: can`t execute safe mount #%d - %s\n", errno, strerror(errno)); | if (kq == -1) { |
close(f); | printf("Error:: can`t execute safe mount #%d - %s\n", errno, strerror(errno)); |
unlink(szSess); | close(f); |
return -1; | unlink(szSess); |
} else { | return -1; |
memset(chg, 0, sizeof(struct kevent)); | } else { |
memset(evt, 0, sizeof(struct kevent)); | memset(chg, 0, sizeof(struct kevent)); |
| memset(evt, 0, sizeof(struct kevent)); |
|
|
EV_SET(chg, f, EVFILT_VNODE, EV_ADD, NOTE_DELETE | NOTE_RENAME | NOTE_REVOKE, | EV_SET(chg, f, EVFILT_VNODE, EV_ADD, NOTE_DELETE | NOTE_RENAME | NOTE_REVOKE, |
0, NULL); | 0, NULL); |
| } |
} |
} |
|
|
return f; |
return f; |
Line 160 s_unlck()
|
Line 162 s_unlck()
|
if (access(szSLCK, F_OK)) |
if (access(szSLCK, F_OK)) |
return 1; |
return 1; |
|
|
if (update(MNT_UPDATE | MNT_RDONLY) == -1) | if (access(szSess, F_OK) && update(MNT_UPDATE | MNT_RDONLY) == -1) |
return 8; |
return 8; |
|
|
unlink(szSLCK); |
unlink(szSLCK); |
Line 182 s_lck(const char *reason)
|
Line 184 s_lck(const char *reason)
|
f = open(szSLCK, O_CREAT | O_WRONLY | O_TRUNC, 0644); |
f = open(szSLCK, O_CREAT | O_WRONLY | O_TRUNC, 0644); |
if (f == -1) { |
if (f == -1) { |
printf("Error:: can`t service lock session #%d - %s\n", errno, strerror(errno)); |
printf("Error:: can`t service lock session #%d - %s\n", errno, strerror(errno)); |
return -1; | return 5; |
} else { |
} else { |
memset(szStr, 0, sizeof szStr); |
memset(szStr, 0, sizeof szStr); |
snprintf(szStr, sizeof szStr, "[%d] - %s", getpid(), reason); |
snprintf(szStr, sizeof szStr, "[%d] - %s", getpid(), reason); |
Line 320 main(int argc, char **argv)
|
Line 322 main(int argc, char **argv)
|
VERB(5) printf("Info(5):: Go safe mount.\n"); |
VERB(5) printf("Info(5):: Go safe mount.\n"); |
setsid(); |
setsid(); |
|
|
if (update(MNT_UPDATE) == -1) | if ((f = mkevent(&chg, &evt)) == -1) |
return 4; |
return 4; |
|
|
if ((f = mkevent(&chg, &evt)) == -1) | if (update(MNT_UPDATE) == -1) |
return 5; |
return 5; |
|
|
if (Timeout) { |
if (Timeout) { |
Line 361 main(int argc, char **argv)
|
Line 363 main(int argc, char **argv)
|
sigprocmask(SIG_BLOCK, &sig, &oldsig); |
sigprocmask(SIG_BLOCK, &sig, &oldsig); |
*/ |
*/ |
|
|
if (update(MNT_UPDATE) == -1) | if ((f = mkevent(NULL, NULL)) == -1) |
return 4; |
return 4; |
|
else |
|
close(f); |
|
|
|
if (update(MNT_UPDATE) == -1) |
|
return 5; |
|
|
switch ((pid = vfork())) { |
switch ((pid = vfork())) { |
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)); |
return 5; | stat = 3; |
| break; |
case 0: |
case 0: |
VERB(5) printf("Go to running process %s\n", *argv); |
VERB(5) printf("Go to running process %s\n", *argv); |
if (chroot(AIT_GET_STR(&Chroot)) == -1) { |
if (chroot(AIT_GET_STR(&Chroot)) == -1) { |
Line 381 main(int argc, char **argv)
|
Line 389 main(int argc, char **argv)
|
/* chdir("/"); */ |
/* chdir("/"); */ |
execvp(*argv, argv); |
execvp(*argv, argv); |
} |
} |
exit(127); | _exit(127); |
break; |
break; |
default: |
default: |
waitpid(pid, &stat, 0); |
waitpid(pid, &stat, 0); |
|
stat = WEXITSTATUS(stat); |
VERB(3) printf("Return code: %d\n", stat); |
VERB(3) printf("Return code: %d\n", stat); |
if (stat == 32512) |
|
stat = 127; |
|
|
|
if (access(szSLCK, F_OK) && update(MNT_UPDATE | MNT_RDONLY) == -1) |
if (access(szSLCK, F_OK) && update(MNT_UPDATE | MNT_RDONLY) == -1) |
return 8; | stat = 8; |
| break; |
} |
} |
|
|
|
unlink(szSess); |
} |
} |
|
|
return stat; |
return stat; |