• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

C/C++ setresuid(3)


New Member

Messages: 7

I am attempting to build Zotonic, the Erlang CMS, but it errors out when compiling exec.cpp.
===>~/zotonic/_build/default/lib/erlexec/c_src/exec.cpp:454:14: error: #error setresuid(3) not supported!
                                                                                                                              #error setresuid(3) not supported!
~/zotonic/_build/default/lib/erlexec/c_src/exec.cpp: In function 'void initialize(int, bool, bool)':
~/zotonic/_build/default/lib/erlexec/c_src/exec.cpp:456:9: error: 
expected primary-expression before '<' token
                < 0) {

gmake:  *** [GNUmakefile:27: compile] Error 1
The section of code for the initialize function is
void initialize(int userid, bool use_alt_fds, bool enable_suid)
    if (getuid() == 0 && userid > 0) {
        if (
            #ifdef HAVE_SETRESUID
            setresuid(-1, userid, geteuid()) // glibc, FreeBSD, OpenBSD, HP-UX
            #elif HAVE_SETREUID
            setreuid(-1, userid)             // MacOSX, NetBSD, AIX, IRIX, Solar
is>=2.5, OSF/1, Cygwin
            #error setresuid(3) not supported!
        < 0) {
            perror("Failed to set effective userid");

        if (debug)
            fprintf(stderr, "Initializing: uid=0, euid=%d, userid=%d%s\r\n",
                getuid(), userid, enable_suid?" enable-suid":"");
Line 454 is "#error setresuid(3) not supported!"
Line 456 is "< 0) {"

Reading the man page for setresuid looks like it is correct, so I'm not sure.


Aspiring Daemon

Thanks: 413
Messages: 860

Read the source code (including header files and make files). Find out where the flag HAVE_SETRESUID is set. It could be in a header file, it could be behind other #if statements, it could be in the make file, it could be using autoconf. Clearly, the fact that you get to the line that does the "#error setresuid not supported" means that neither HAVE_SETRESUID nor HAVE_SETREUID have been set.

The second error is just a side effect of the first: if you look at the syntax of the if statement and take out all the precompiler statements (the ones that start with #), what is left is: "if ( < 0) { ...", and that's obviously not valid.


New Member

Messages: 7

Not sure if what I've done is right because I'm only a very modest intermediate C programmer and certainly am not a C++ programmer. What I did for exec.cpp
//setresuid(-1, userid, geteuid())
setresuid(-1, 1001, 0)
Then it complained about the same error in exec_impl.cpp but that was
#if !defined(__CYGWIN__) && !defined(__WIN32)
So I commented out that section where it sets euid.

The last error was also in the exec_impl.cpp
r = ptsname_r(fdm, pts_name, sizeof(pts_name));
I changed ptsname_r to ttyname_r.

After those three changes then Zotonic was able to build successfully. I previously built Zotonic on OpenIndiana and ran into a couple of problems but worked around them and sent an email to the Zotonic team of my changes to get it to build successfully, and had a reply. I'll make note of these changes and send them again to the Zotonic team and see what they say.