Tag Info

New answers tagged

1

Your scenario works perfectly here for me. $ ls -l test* -rwsr-xr-x 1 root root 6776 Jan 24 17:18 test -rw-r--r-- 1 chris chris 74 Jan 24 17:18 test.c -rw-r----- 1 root root 0 Jan 24 17:20 test.txt $ ./test ls -l test.txt -rw-r----- 1 root root 4 Jan 24 17:21 test.txt $ sudo cat test.txt 100 Is it possible that you're testing your program on a ...


-2

The problem is, you call the function system(), which calls a shell /bin/sh. And the shell /bin/sh has no suid bit set. Thats why is prints the Permission denied message. You have to write the part in pure c code: int main() { FILE *fd = fopen("test.txt", "a"); fprintf(fd, "%s", "100"); fclose(fd); return 0; }


5

You have to compile it; as in: gcc -o soma soma.c Then run by: ./soma As of now you are running is as a script with what ever shell you are using. A better compile line would be: gcc -Wall -Wextra -pedantic -o soma soma.c That line will give you a lot of help and hints. And always remember to compile often so you do not have to fix walls of errors ...



Top 50 recent answers are included