Link to home
Start Free TrialLog in
Avatar of joleen2
joleen2

asked on

What Library do I use for setfsuid()

I keep getting the warning "implicit declaration of function setfsuid()". It has been my experience that I am missing either a #include or #define statement at the beginning of my program. The man pages don't say what to use. Do you have any ideas?
ASKER CERTIFIED SOLUTION
Avatar of modulus
modulus

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jlevie
jlevie

All that means is that the compiler doesn't know the return type for the function. The doc's don't indicate that a header file is needed, not surprising as it returns an int, and takes as and arg a uid_t... Nothing fancy here and the compiler knows the types.

If it bothers you, include an "int setfsuid();" declaration.
modulus,

Which linux? On RH 6.1 man 2 setfsuid doesn't reference the include file (tho I agree it's there).
Avatar of joleen2

ASKER

RH 5.0. I like a clean build.
Hi jlevie,
I use a mixture of info, man, grep and etags (built for all libc) and emacs (C-h C-i) to find out what things are.  I found it I think from using the tags for the library.  I'm not sure whether it's better to declare the function as you suggest or to use a previously existing one.  I'd tend toward the latter though.  No, I don't have a nice version of the man pages!  I'm using RH6.1 at present too.
Best wishes,
modulus
Avatar of joleen2

ASKER

I tried writing a prototype, no go. I tried declaring in after the call, no go. I get an error of either, "to many arguments" or "undefined reference." I am at a loss.
Avatar of joleen2

ASKER

Modulus,
Thank you. I am new to this site and am fiquring it out. I finally saw your note to use #include/sys/fsuid. It worked. How or where did you locate this info? I have been trying to find this out for 2 months.  Many thanks Joleen
joleen2,
hello again.  Supposedly you should be able to find out all that you need to know from the man pages.  Don't believe it!  Although they are fine documents and a lot of people have given their time to create this resource it tends to be a bit patchy. Also man pages are deprecated by the FSF and consequently a lot of the documentation is better if you use "info".  Info can be a bit awkward at first, but once you get used to it there's a lot there, especially if you examine the libc entry and especially if you use emacs.  In emacs you can just position the cursor on a function or macro and type C-h C-i and it'll go search for the libc entry.
      Then there are tags - tables of definitions that you can create using etags (for emacs and ctags I think for vi?) which when in emacs you type Meta-. brings you to the actual definition.
      Then there's using grep.  If you are aware of the locations of the c library on your system then you can very profitably type:
grep -e "setfsuid" /usr/include/sys/*
and see what turns up.  The File System Hierarchy specifications are a great help in this if your system adheres to them.
Hope that helps.  If there's any more you want to know, don't hesitate to ask.
Best wishes,
Modulus
Avatar of joleen2

ASKER

Thank you that is great information. Just one other question about this site. How did you know I emailed you? Does the fact that I write a message in the comments section when I am responding to a response to my question send you an email too?
When you comment on the site then an email is sent automatically to those that enable this option.