#linux #nextcloud
#linux #nextcloud
Вопрос:
Другие команды, такие как chown и т. Д., Работают, Так что это как-то связано с snap или nextcloud-snap.
Я попробовал следующее:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> /* for fork */
#include <sys/types.h> /* for pid_t */
#include <sys/wait.h> /* for wait */
int main()
{
setuid(0);
/*Spawn a child to run the program.*/
pid_t pid=fork();
if (pid==0) { /* child process */
static char *argv[]={"nextcloud.occ","nextcloud.occ files:scan Administrator",NULL};
execv("/snap/bin/nextcloud.occ",argv);
exit(127); /* only if execv fails */
}
else { /* pid!=0; parent process */
waitpid(pid,0,0); /* wait for child to exit */
}
return 0;
}
Я побежал
gcc -o posttorrent posttorrent.c
sudo chown root posttorrent
sudo chmod ug s posttorrent
запуск программы приводит к:
permanently dropping privs did not work: File exists
затем последовательность выполнения программы приводит к:
debian-transmission@ubuntu:/transmission-data$ strace ./posttorrent
execve("./posttorrent", ["./posttorrent"], 0xffffd2e7a1e0 /* 13 vars */) = 0
faccessat(AT_FDCWD, "/etc/suid-debug", F_OK) = -1 ENOENT (No such file or directory)
brk(NULL) = 0xaaaafeb52000
fcntl(0, F_GETFD) = 0
fcntl(1, F_GETFD) = 0
fcntl(2, F_GETFD) = 0
faccessat(AT_FDCWD, "/etc/suid-debug", F_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=27061, ...}) = 0
mmap(NULL, 27061, PROT_READ, MAP_PRIVATE, 3, 0) = 0xffffaace6000
close(3) = 0
openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF211332671350A2"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1441800, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xffffaace4000
mmap(NULL, 1510480, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xffffaab4d000
mprotect(0xffffaaca6000, 61440, PROT_NONE) = 0
mmap(0xffffaacb5000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x158000) = 0xffffaacb5000
mmap(0xffffaacbb000, 11344, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xffffaacbb000
close(3) = 0
mprotect(0xffffaacb5000, 12288, PROT_READ) = 0
mprotect(0xaaaad56ed000, 4096, PROT_READ) = 0
mprotect(0xffffaacef000, 4096, PROT_READ) = 0
munmap(0xffffaace6000, 27061) = 0
setuid(0) = -1 EPERM (Operation not permitted)
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xffffaace4cf0) = 762022
wait4(762022, 2020/12/21 20:27:47.533491 cmd_run.go:994: WARNING: cannot create user data directory: cannot create "/var/lib/transmission-daemon/snap/nextcloud/24943": mkdir /var/lib/transmission-daemon/snap: permission denied
Sorry, home directories outside of /home are not currently supported.
See https://forum.snapcraft.io/t/11209 for details.
NULL, 0, NULL) = 762022
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=762022, si_uid=112, si_status=1, si_utime=2, si_stime=5} ---
exit_group(0) = ?
exited with 0
Комментарии:
1. Не нравится, потому что? разве это невозможно? что я сделал не так?