LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 07-07-2004, 06:46 PM   #1
rajatgarg
Member
 
Registered: Oct 2003
Posts: 41

Rep: Reputation: 15
Unhappy 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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Latest quota-tools rpm - Where to find pls? (Newbie) KDoc Red Hat 0 08-10-2004 11:40 PM
pls help me to find a multimedia player sanjaya Linux - Software 8 02-16-2004 10:25 PM
pls pls pls help me ! i'm tired with httpd config on fedora apache 2.0.48 AngelOfTheDamn Fedora 0 01-24-2004 05:12 PM
Mail Problem, pls help kcwoo Linux - General 1 02-07-2002 02:55 PM
trouble pls help BZFlag crashes no error message that I can find Cor_Tauri Linux - Newbie 2 07-15-2001 06:49 PM


All times are GMT -5. The time now is 02:59 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration