C setresuid(3)

I am attempting to build Zotonic, the Erlang CMS, but it errors out when compiling exec.cpp.
Code:
===>~/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
Code:
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
            #else
            #error setresuid(3) not supported!
            #endif
        < 0) {
            perror("Failed to set effective userid");
            exit(4);
        }

        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.
 
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.
 
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
Code:
//setresuid(-1, userid, geteuid())
setresuid(-1, 1001, 0)
Then it complained about the same error in exec_impl.cpp but that was
Code:
#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
Code:
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.
 
I created an issue with Zotonic who requested an update to erlexec from the maintainer, then Zotonic updated their dependencies.

Issue filed Tuesday and resolved Thursday.

Erlang CMS
 
Back
Top