cant find the problem..pls help ?????
Hi Gurus,
need your help, i am stuck with this piece of code where I try to run exportfs -r from my C code. No error is reported but nothing expected comes out either. Here is what I do: (/etc/exports is modified, which confirms that setuid is working ok) #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { /* getting and setting advanced permissions for the script */ int ruid = getuid(); int euid = geteuid(); strcpy(root_fs, argv[1]); if (setuid(euid) == -1) { return 1; } fd = fopen("/etc/exports", "r+"); if (fd == NULL) { printf("Error: can't open file.\n"); setuid(ruid); return 1; } /* Adding the line in /etc/exports */ fprintf(fd, "%s", argv[1]); fprintf(fd, "%s", " *(rw)"); fprintf(fd, "%s", "\n"); /* Executing exportfs -a */ execlp("/usr/sbin/exportfs","-r",NULL); // retval = system("/usr/sbin/exportfs -r"); if (retval != 0){ printf("Error in executing exportfs -r"); setuid(ruid); return 1; } setuid(ruid); fclose(fd); return 0; } Any help will be greatly appreciated |
All times are GMT -5. The time now is 03:35 AM. |