mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-25 19:14:04 +00:00
Drop \n from pr_perror
Another pr_perror spring cleaning time! As pr_perror adds a semicolon, an strerror(errno), and a newline, there's no need to add one manually. Brought to you by for f in $(git grep -l pr_perror); do test -f $f || continue echo $f sed -i '\%^[[:space:]]*pr_perror(.*\\n"%s/\\n//' $f done Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
5e3b07b95d
commit
f3be776ccc
29 changed files with 76 additions and 76 deletions
|
|
@ -196,13 +196,13 @@ int get_vx_regs(pid_t pid, user_fpregs_struct_t *fpregs)
|
|||
pr_debug("VXRS registers not supported\n");
|
||||
return 0;
|
||||
}
|
||||
pr_perror("Couldn't get VXRS_LOW\n");
|
||||
pr_perror("Couldn't get VXRS_LOW");
|
||||
return -1;
|
||||
}
|
||||
iov.iov_base = &fpregs->vxrs_high;
|
||||
iov.iov_len = sizeof(fpregs->vxrs_high);
|
||||
if (ptrace(PTRACE_GETREGSET, pid, NT_S390_VXRS_HIGH, &iov) < 0) {
|
||||
pr_perror("Couldn't get VXRS_HIGH\n");
|
||||
pr_perror("Couldn't get VXRS_HIGH");
|
||||
return -1;
|
||||
}
|
||||
fpregs->flags |= USER_FPREGS_VXRS;
|
||||
|
|
@ -243,7 +243,7 @@ int get_gs_cb(pid_t pid, user_fpregs_struct_t *fpregs)
|
|||
pr_debug("GS_BC not set\n");
|
||||
return 0;
|
||||
}
|
||||
pr_perror("Couldn't get GS_BC\n");
|
||||
pr_perror("Couldn't get GS_BC");
|
||||
return -1;
|
||||
}
|
||||
fpregs->flags |= USER_GS_BC;
|
||||
|
|
@ -274,7 +274,7 @@ int get_ri_cb(pid_t pid, user_fpregs_struct_t *fpregs)
|
|||
pr_debug("RI_CB not set\n");
|
||||
return 0;
|
||||
default:
|
||||
pr_perror("Couldn't get RI_CB\n");
|
||||
pr_perror("Couldn't get RI_CB");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -386,14 +386,14 @@ int compel_set_task_ext_regs(pid_t pid, user_fpregs_struct_t *ext_regs)
|
|||
iov.iov_base = &ext_regs->vxrs_low;
|
||||
iov.iov_len = sizeof(ext_regs->vxrs_low);
|
||||
if (ptrace(PTRACE_SETREGSET, pid, NT_S390_VXRS_LOW, &iov) < 0) {
|
||||
pr_perror("Couldn't set VXRS_LOW\n");
|
||||
pr_perror("Couldn't set VXRS_LOW");
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
iov.iov_base = &ext_regs->vxrs_high;
|
||||
iov.iov_len = sizeof(ext_regs->vxrs_high);
|
||||
if (ptrace(PTRACE_SETREGSET, pid, NT_S390_VXRS_HIGH, &iov) < 0) {
|
||||
pr_perror("Couldn't set VXRS_HIGH\n");
|
||||
pr_perror("Couldn't set VXRS_HIGH");
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -402,13 +402,13 @@ int compel_set_task_ext_regs(pid_t pid, user_fpregs_struct_t *ext_regs)
|
|||
iov.iov_base = &ext_regs->gs_cb;
|
||||
iov.iov_len = sizeof(ext_regs->gs_cb);
|
||||
if (ptrace(PTRACE_SETREGSET, pid, NT_S390_GS_CB, &iov) < 0) {
|
||||
pr_perror("Couldn't set GS_CB\n");
|
||||
pr_perror("Couldn't set GS_CB");
|
||||
ret = -1;
|
||||
}
|
||||
iov.iov_base = &ext_regs->gs_bc;
|
||||
iov.iov_len = sizeof(ext_regs->gs_bc);
|
||||
if (ptrace(PTRACE_SETREGSET, pid, NT_S390_GS_BC, &iov) < 0) {
|
||||
pr_perror("Couldn't set GS_BC\n");
|
||||
pr_perror("Couldn't set GS_BC");
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -417,7 +417,7 @@ int compel_set_task_ext_regs(pid_t pid, user_fpregs_struct_t *ext_regs)
|
|||
iov.iov_base = &ext_regs->ri_cb;
|
||||
iov.iov_len = sizeof(ext_regs->ri_cb);
|
||||
if (ptrace(PTRACE_SETREGSET, pid, NT_S390_RI_CB, &iov) < 0) {
|
||||
pr_perror("Couldn't set RI_CB\n");
|
||||
pr_perror("Couldn't set RI_CB");
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ int __compel_arch_fetch_thread_area(int tid, struct thread_ctx *th)
|
|||
if (err == -EIO && native_mode)
|
||||
return 0;
|
||||
if (err) {
|
||||
pr_perror("get_thread_area failed for %d\n", tid);
|
||||
pr_perror("get_thread_area failed for %d", tid);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ int kdat_x86_has_ptrace_fpu_xsave_bug(void)
|
|||
* waitpid() may end with ECHILD if SIGCHLD == SIG_IGN,
|
||||
* and the child has stopped already.
|
||||
*/
|
||||
pr_perror("Failed to wait for %s() test\n", __func__);
|
||||
pr_perror("Failed to wait for %s() test", __func__);
|
||||
goto out_kill;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1224,7 +1224,7 @@ static int wait_exiting_children(void)
|
|||
futex_dec_and_wake(&task_entries->nr_in_progress);
|
||||
|
||||
if (waitid(P_ALL, 0, &info, WEXITED | WNOWAIT)) {
|
||||
pr_perror("Failed to wait\n");
|
||||
pr_perror("Failed to wait");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ int fdstore_add(int fd)
|
|||
|
||||
ret = send_fd(sk, NULL, 0, fd);
|
||||
if (ret) {
|
||||
pr_perror("Can't send fd %d into store\n", fd);
|
||||
pr_perror("Can't send fd %d into store", fd);
|
||||
mutex_unlock(&desc->lock);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -479,7 +479,7 @@ static int open_break_cb(int ns_root_fd, struct reg_file_info *rfi, void *arg)
|
|||
close(fd);
|
||||
return -1;
|
||||
} else if (errno != EWOULDBLOCK) {
|
||||
pr_perror("Can't break lease\n");
|
||||
pr_perror("Can't break lease");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -512,7 +512,7 @@ static int set_file_lease(int fd, int type)
|
|||
struct stat st;
|
||||
|
||||
if (fstat(fd, &st)) {
|
||||
pr_perror("Can't get file stat (%i)\n", fd);
|
||||
pr_perror("Can't get file stat (%i)", fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -524,7 +524,7 @@ static int set_file_lease(int fd, int type)
|
|||
|
||||
ret = fcntl(fd, F_SETLEASE, type);
|
||||
if (ret < 0)
|
||||
pr_perror("Can't set lease\n");
|
||||
pr_perror("Can't set lease");
|
||||
|
||||
setfsuid(old_fsuid);
|
||||
return ret;
|
||||
|
|
@ -589,20 +589,20 @@ static int restore_file_lease(FileLockEntry *fle)
|
|||
signum_fcntl = fcntl(fle->fd, F_GETSIG);
|
||||
signum = signum_fcntl ? signum_fcntl : SIGIO;
|
||||
if (signum_fcntl < 0) {
|
||||
pr_perror("Can't get file i/o signum\n");
|
||||
pr_perror("Can't get file i/o signum");
|
||||
return -1;
|
||||
}
|
||||
if (sigemptyset(&blockmask) ||
|
||||
sigaddset(&blockmask, signum) ||
|
||||
sigprocmask(SIG_BLOCK, &blockmask, &oldmask)) {
|
||||
pr_perror("Can't block file i/o signal\n");
|
||||
pr_perror("Can't block file i/o signal");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = restore_breaking_file_lease(fle);
|
||||
|
||||
if (sigprocmask(SIG_SETMASK, &oldmask, NULL)) {
|
||||
pr_perror("Can't restore sigmask\n");
|
||||
pr_perror("Can't restore sigmask");
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -1045,7 +1045,7 @@ static bool kerndat_has_clone3_set_tid(void)
|
|||
if (pid == -1 && errno == EINVAL) {
|
||||
kdat.has_clone3_set_tid = true;
|
||||
} else {
|
||||
pr_perror("Unexpected error from clone3\n");
|
||||
pr_perror("Unexpected error from clone3");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -471,12 +471,12 @@ static int vdso_mmap_compat(struct vdso_maps *native,
|
|||
goto out_kill;
|
||||
|
||||
if (kill(pid, SIGCONT)) {
|
||||
pr_perror("Failed to kill(SIGCONT) for compat vdso helper\n");
|
||||
pr_perror("Failed to kill(SIGCONT) for compat vdso helper");
|
||||
goto out_kill;
|
||||
}
|
||||
if (write(fds[1], &compat->vdso_start, sizeof(void *)) !=
|
||||
sizeof(compat->vdso_start)) {
|
||||
pr_perror("Failed write to pipe\n");
|
||||
pr_perror("Failed write to pipe");
|
||||
goto out_kill;
|
||||
}
|
||||
waitpid(pid, &status, WUNTRACED);
|
||||
|
|
|
|||
|
|
@ -372,7 +372,7 @@ int test_wait_pre_dump(void)
|
|||
|
||||
if (read(criu_status_in, &ret, sizeof(ret)) != sizeof(ret)) {
|
||||
if (errno != EBADF || !futex_get(&sig_received))
|
||||
pr_perror("Can't wait pre-dump\n");
|
||||
pr_perror("Can't wait pre-dump");
|
||||
return -1;
|
||||
}
|
||||
pr_err("pre-dump\n");
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ static int read_one_priomap(char *prop_line, struct ifpriomap_t *out)
|
|||
|
||||
out->ifname = malloc(len + 1);
|
||||
if (!out->ifname) {
|
||||
pr_perror("malloc() failed\n");
|
||||
pr_perror("malloc() failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ int main(int argc, char *argv[])
|
|||
uint8_t cw = 1, cr;
|
||||
|
||||
if (write(pipes[i].pipefd[1], &cw, sizeof(cw)) != sizeof(cw)) {
|
||||
pr_perror("Unable to write into a pipe\n");
|
||||
pr_perror("Unable to write into a pipe");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ int main(int argc, char *argv[])
|
|||
uint8_t cw = 1, cr;
|
||||
|
||||
if (write(pipes[i].pipefd[1], &cw, sizeof(cw)) != sizeof(cw)) {
|
||||
pr_perror("Unable to write into a pipe\n");
|
||||
pr_perror("Unable to write into a pipe");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ static int check_lease_type(int fd, int expected_type)
|
|||
|
||||
if (lease_type != expected_type) {
|
||||
if (lease_type < 0)
|
||||
pr_perror("Can't acquire lease type\n");
|
||||
pr_perror("Can't acquire lease type");
|
||||
else
|
||||
pr_err("Mismatched lease type: %i\n", lease_type);
|
||||
return -1;
|
||||
|
|
@ -64,7 +64,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
if (fcntl(fd_rd, F_SETLEASE, F_RDLCK) < 0 ||
|
||||
fcntl(fd_wr, F_SETLEASE, F_WRLCK) < 0) {
|
||||
pr_perror("Can't set leases\n");
|
||||
pr_perror("Can't set leases");
|
||||
close_files(fd_rd, fd_wr);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ static int check_lease_type(int fd, int expected_type)
|
|||
|
||||
if (lease_type != expected_type) {
|
||||
if (lease_type < 0)
|
||||
pr_perror("Can't acquire lease type\n");
|
||||
pr_perror("Can't acquire lease type");
|
||||
else
|
||||
pr_err("Mismatched lease type: %i\n", lease_type);
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ static int check_lease_type(int fd, int expected_type)
|
|||
|
||||
if (lease_type != expected_type) {
|
||||
if (lease_type < 0)
|
||||
pr_perror("Can't acquire lease type\n");
|
||||
pr_perror("Can't acquire lease type");
|
||||
else
|
||||
pr_err("Mismatched lease type: %i\n", lease_type);
|
||||
return -1;
|
||||
|
|
@ -54,15 +54,15 @@ static int prepare_file(char *file, int file_type, int break_type)
|
|||
|
||||
fd = open(file, file_type | O_CREAT, 0666);
|
||||
if (fd < 0) {
|
||||
pr_perror("Can't open file (type %i)\n", file_type);
|
||||
pr_perror("Can't open file (type %i)", file_type);
|
||||
return fd;
|
||||
}
|
||||
if (fcntl(fd, F_SETLEASE, lease_type) < 0) {
|
||||
pr_perror("Can't set exclusive lease\n");
|
||||
pr_perror("Can't set exclusive lease");
|
||||
goto err;
|
||||
}
|
||||
if (fcntl(fd, F_SETSIG, BREAK_SIGNUM) < 0) {
|
||||
pr_perror("Can't set signum for file i/o\n");
|
||||
pr_perror("Can't set signum for file i/o");
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ static int prepare_file(char *file, int file_type, int break_type)
|
|||
pr_err("Conflicting lease not found\n");
|
||||
goto err;
|
||||
} else if (errno != EWOULDBLOCK) {
|
||||
pr_perror("Can't break lease\n");
|
||||
pr_perror("Can't break lease");
|
||||
goto err;
|
||||
}
|
||||
return fd;
|
||||
|
|
@ -114,7 +114,7 @@ int main(int argc, char **argv)
|
|||
if (sigemptyset(&act.sa_mask) ||
|
||||
sigaddset(&act.sa_mask, BREAK_SIGNUM) ||
|
||||
sigaction(BREAK_SIGNUM, &act, NULL)) {
|
||||
pr_perror("Can't set signal action\n");
|
||||
pr_perror("Can't set signal action");
|
||||
fail();
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ static int check_lease_type(int fd, int expected_type)
|
|||
|
||||
if (lease_type != expected_type) {
|
||||
if (lease_type < 0)
|
||||
pr_perror("Can't acquire lease type\n");
|
||||
pr_perror("Can't acquire lease type");
|
||||
else
|
||||
pr_err("Mismatched lease type: %i\n", lease_type);
|
||||
return -1;
|
||||
|
|
@ -49,15 +49,15 @@ static int prepare_file(char *file, int file_type, int break_type)
|
|||
|
||||
fd = open(file, file_type | O_CREAT, 0666);
|
||||
if (fd < 0) {
|
||||
pr_perror("Can't open file (type %i)\n", file_type);
|
||||
pr_perror("Can't open file (type %i)", file_type);
|
||||
return fd;
|
||||
}
|
||||
if (fcntl(fd, F_SETLEASE, lease_type) < 0) {
|
||||
pr_perror("Can't set exclusive lease\n");
|
||||
pr_perror("Can't set exclusive lease");
|
||||
goto err;
|
||||
}
|
||||
if (fcntl(fd, F_SETSIG, BREAK_SIGNUM) < 0) {
|
||||
pr_perror("Can't set signum for file i/o\n");
|
||||
pr_perror("Can't set signum for file i/o");
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ static int prepare_file(char *file, int file_type, int break_type)
|
|||
pr_err("Conflicting lease not found\n");
|
||||
goto err;
|
||||
} else if (errno != EWOULDBLOCK) {
|
||||
pr_perror("Can't break lease\n");
|
||||
pr_perror("Can't break lease");
|
||||
goto err;
|
||||
}
|
||||
return fd;
|
||||
|
|
@ -92,7 +92,7 @@ int main(int argc, char **argv)
|
|||
if (sigemptyset(&act.sa_mask) ||
|
||||
sigaddset(&act.sa_mask, BREAK_SIGNUM) ||
|
||||
sigaction(BREAK_SIGNUM, &act, NULL)) {
|
||||
pr_perror("Can't set signal action\n");
|
||||
pr_perror("Can't set signal action");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ int main(int argc, char **argv)
|
|||
|
||||
ret = fd_dup = dup(fd);
|
||||
if (fd_dup < 0) {
|
||||
pr_perror("Can't dup fd\n");
|
||||
pr_perror("Can't dup fd");
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ static int check_lease_type(int fd, int expected_type)
|
|||
|
||||
if (lease_type != expected_type) {
|
||||
if (lease_type < 0)
|
||||
pr_perror("Can't acquire lease type\n");
|
||||
pr_perror("Can't acquire lease type");
|
||||
else
|
||||
pr_err("Mismatched lease type: %i\n", lease_type);
|
||||
return -1;
|
||||
|
|
@ -49,15 +49,15 @@ static int prepare_file(char *file, int file_type, int break_type)
|
|||
|
||||
fd = open(file, file_type | O_CREAT, 0666);
|
||||
if (fd < 0) {
|
||||
pr_perror("Can't open file (type %i)\n", file_type);
|
||||
pr_perror("Can't open file (type %i)", file_type);
|
||||
return fd;
|
||||
}
|
||||
if (fcntl(fd, F_SETLEASE, lease_type) < 0) {
|
||||
pr_perror("Can't set exclusive lease\n");
|
||||
pr_perror("Can't set exclusive lease");
|
||||
goto err;
|
||||
}
|
||||
if (fcntl(fd, F_SETSIG, BREAK_SIGNUM) < 0) {
|
||||
pr_perror("Can't set signum for file i/o\n");
|
||||
pr_perror("Can't set signum for file i/o");
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ static int prepare_file(char *file, int file_type, int break_type)
|
|||
pr_err("Conflicting lease not found\n");
|
||||
goto err;
|
||||
} else if (errno != EWOULDBLOCK) {
|
||||
pr_perror("Can't break lease\n");
|
||||
pr_perror("Can't break lease");
|
||||
goto err;
|
||||
}
|
||||
return fd;
|
||||
|
|
@ -92,7 +92,7 @@ int main(int argc, char **argv)
|
|||
if (sigemptyset(&act.sa_mask) ||
|
||||
sigaddset(&act.sa_mask, BREAK_SIGNUM) ||
|
||||
sigaction(BREAK_SIGNUM, &act, NULL)) {
|
||||
pr_perror("Can't set signal action\n");
|
||||
pr_perror("Can't set signal action");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,10 +36,10 @@ int init_lock(int *fd, struct flock *lck)
|
|||
void cleanup(int *fd)
|
||||
{
|
||||
if (close(*fd))
|
||||
pr_perror("Can't close fd\n");
|
||||
pr_perror("Can't close fd");
|
||||
|
||||
if (unlink(filename))
|
||||
pr_perror("Can't unlink file\n");
|
||||
pr_perror("Can't unlink file");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
|
|||
|
|
@ -59,10 +59,10 @@ void cleanup(void)
|
|||
|
||||
for (i = 0; i < FILE_NUM; ++i)
|
||||
if (close(fds[i]))
|
||||
pr_perror("Can't close fd\n");
|
||||
pr_perror("Can't close fd");
|
||||
|
||||
if (unlink(filename))
|
||||
pr_perror("Can't unlink file failed\n");
|
||||
pr_perror("Can't unlink file failed");
|
||||
}
|
||||
|
||||
int check_file_locks_restored(void)
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@ int init_file_lock(int *fd, struct flock *lck)
|
|||
void cleanup(int *fd)
|
||||
{
|
||||
if (close(*fd))
|
||||
pr_perror("Can't close fd\n");
|
||||
pr_perror("Can't close fd");
|
||||
|
||||
if (unlink(filename))
|
||||
pr_perror("Can't unlink file\n");
|
||||
pr_perror("Can't unlink file");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
|
|||
|
|
@ -92,12 +92,12 @@ int main(int argc, char ** argv)
|
|||
void *ret;
|
||||
|
||||
if (pthread_create(&child, NULL, &run_fpu_test, NULL)) {
|
||||
pr_perror("Can't create pthread\n");
|
||||
pr_perror("Can't create pthread");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (pthread_join(child, &ret)) {
|
||||
pr_perror("Can't join pthread\n");
|
||||
pr_perror("Can't join pthread");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ int main(int argc, char ** argv)
|
|||
MAP_ANONYMOUS | MAP_SHARED, -1, 0);
|
||||
|
||||
if (wait_rdy == MAP_FAILED || wait_run == MAP_FAILED) {
|
||||
pr_perror("mmap failed\n");
|
||||
pr_perror("mmap failed");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,12 +78,12 @@ int main(int argc, char *argv[])
|
|||
|
||||
sk = socket(AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0);
|
||||
if (sk < 0) {
|
||||
pr_perror("socket\n");
|
||||
pr_perror("socket");
|
||||
exit(1);
|
||||
}
|
||||
csk = socket(AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0);
|
||||
if (csk < 0) {
|
||||
pr_perror("socket\n");
|
||||
pr_perror("socket");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ int main(int argc, char *argv[])
|
|||
close(csk);
|
||||
csk = socket(AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0);
|
||||
if (csk < 0) {
|
||||
pr_perror("socket\n");
|
||||
pr_perror("socket");
|
||||
exit(1);
|
||||
}
|
||||
if (connect(csk, (struct sockaddr *) &addr, addrlen)) {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ static int child_func(void *fd_p)
|
|||
|
||||
/* If sks[1] == fd, the below closes it, but we don't care */
|
||||
if (dup2(sks[0], fd) == -1) {
|
||||
pr_perror("Can't dup fd\n");
|
||||
pr_perror("Can't dup fd");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
if (wait(&status) == -1 || status) {
|
||||
pr_perror("wait error: status=%d\n", status);
|
||||
pr_perror("wait error: status=%d", status);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ int main(int argc, char *argv[])
|
|||
test_waitsig();
|
||||
|
||||
if (unlink(path)) {
|
||||
pr_perror("Unable to remove %s\n", path);
|
||||
pr_perror("Unable to remove %s", path);
|
||||
return 1;
|
||||
}
|
||||
if (rmdir(dir)) {
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ int main(int argc, char **argv)
|
|||
|
||||
close(pfd[1]);
|
||||
if (read(pfd[0], &port, sizeof(port)) != sizeof(port)) {
|
||||
pr_perror("Can't read port\n");
|
||||
pr_perror("Can't read port");
|
||||
return 1;
|
||||
}
|
||||
close(pfd[0]);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ static int check_socket_closed(int sk)
|
|||
|
||||
err = getsockopt(sk, IPPROTO_TCP, TCP_INFO, (void *)&info, &len);
|
||||
if (err != 0) {
|
||||
pr_perror("Can't get socket state\n");
|
||||
pr_perror("Can't get socket state");
|
||||
return -1;
|
||||
} else if (info.tcpi_state != TCP_CLOSE) {
|
||||
pr_err("Invalid socket state (%i)", (int)info.tcpi_state);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ static int check_socket_state(int sk, int state)
|
|||
|
||||
err = getsockopt(sk, IPPROTO_TCP, TCP_INFO, (void *)&info, &len);
|
||||
if (err != 0) {
|
||||
pr_perror("Can't get socket state\n");
|
||||
pr_perror("Can't get socket state");
|
||||
return -1;
|
||||
}
|
||||
return info.tcpi_state == state ? 0 : -1;
|
||||
|
|
|
|||
|
|
@ -39,19 +39,19 @@ void *chg_uid_gid(void *arg)
|
|||
|
||||
newcaps = cap_from_text("cap_setgid,cap_setuid=+eip");
|
||||
if (!newcaps) {
|
||||
pr_perror("Failed to get capability struct\n");
|
||||
pr_perror("Failed to get capability struct");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret = cap_set_proc(newcaps);
|
||||
if (ret) {
|
||||
pr_perror("Failed to set capabilities for the process\n");
|
||||
pr_perror("Failed to set capabilities for the process");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
mycaps = cap_get_proc();
|
||||
if (!mycaps) {
|
||||
pr_perror("Failed to get child thread capabilities\n");
|
||||
pr_perror("Failed to get child thread capabilities");
|
||||
exit_group(2);
|
||||
}
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ void *chg_uid_gid(void *arg)
|
|||
if (ret >= 0) {
|
||||
syscall(SYS_setresuid, uid, uid, uid);
|
||||
} else if (ret < 0) {
|
||||
pr_perror("Failed to change UID/GID\n");
|
||||
pr_perror("Failed to change UID/GID");
|
||||
exit_group(2);
|
||||
}
|
||||
|
||||
|
|
@ -103,17 +103,17 @@ int main(int argc, char **argv)
|
|||
|
||||
newcaps = cap_from_text("cap_setgid,cap_setuid=+eip");
|
||||
if (!newcaps) {
|
||||
pr_perror("Failed to get capability struct\n");
|
||||
pr_perror("Failed to get capability struct");
|
||||
exit(1);
|
||||
}
|
||||
ret = cap_set_proc(newcaps);
|
||||
if (ret) {
|
||||
pr_perror("Failed to set capabilities for the process\n");
|
||||
pr_perror("Failed to set capabilities for the process");
|
||||
exit(1);
|
||||
}
|
||||
ret = prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);
|
||||
if (ret) {
|
||||
pr_perror("Unable to set KEEPCAPS\n");
|
||||
pr_perror("Unable to set KEEPCAPS");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -132,12 +132,12 @@ int main(int argc, char **argv)
|
|||
if (ret >= 0) {
|
||||
ret = syscall(SYS_setresuid, mainuser, mainuser, mainuser);
|
||||
} else if (ret < 0) {
|
||||
pr_perror("Failed to drop privileges\n");
|
||||
pr_perror("Failed to drop privileges");
|
||||
exit(1);
|
||||
}
|
||||
test_msg("Now main thread runs as UID: %d; GID: %d\n", getuid(), getgid());
|
||||
if (gid == getgid() || uid == getuid()) {
|
||||
pr_perror("Thread credentials match\n");
|
||||
pr_perror("Thread credentials match");
|
||||
exit(1);
|
||||
}
|
||||
test_msg("Main thread is waiting for signal\n");
|
||||
|
|
@ -146,7 +146,7 @@ int main(int argc, char **argv)
|
|||
test_waitsig();
|
||||
|
||||
if (gid == getgid() || uid == getuid()) {
|
||||
pr_perror("Thread credentials match after restore\n");
|
||||
pr_perror("Thread credentials match after restore");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue