Bug 940 - error: unknown type name '__dso_public'
error: unknown type name '__dso_public'
Status: RESOLVED FIXED
Product: Sudo
Classification: Unclassified
Component: Configure
1.9.2
PC Linux
: low normal
Assigned To: Todd C. Miller
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2020-09-17 15:22 MDT by Ivan Farkov
Modified: 2020-09-23 05:30 MDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Farkov 2020-09-17 15:22:14 MDT
I am trying to cross-compile sudo-1.9.2 for Android (armv7a) on Debian.
Got this error about '__dso_public' in stderr output:

configure: WARNING: using cross tools not prefixed with host triplet
configure: WARNING: Replacing missing/broken (v)snprintf() with sudo's version.
-------------------------------- make --------------------------------
./sudo_debug.c:170:75: warning: 'open' has superfluous mode bits; missing O_CREAT? [-Wuser-defined-warnings]
    output->fd = open(output->filename, O_WRONLY|O_APPEND, S_IRUSR|S_IWUSR);
                                                                          ^
/home/user/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/bits/fortify/fcntl.h:76:9: note: from 'diagnose_if' attribute on 'open':
        __clang_warning_if(!__open_modes_useful(flags) && modes,
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/user/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/sys/cdefs.h:135:54: note: expanded from macro '__clang_warning_if'
#define __clang_warning_if(cond, msg) __attribute__((diagnose_if(cond, msg, "warning")))
                                                     ^           ~~~~
1 warning generated.
./iolog_fileio.c:705:8: warning: implicit declaration of function 'fseeko' is invalid in C99 [-Wimplicit-function-declaration]
        ret = fseeko(iol->fd.f, offset, whence);
              ^
1 warning generated.
./eventlog.c:620:16: warning: implicit declaration of function 'fseeko' is invalid in C99 [-Wimplicit-function-declaration]
    } else if (fseeko(fp, -3, SEEK_END) == 0) {
               ^
1 warning generated.
./audit_json.c:385:16: warning: implicit declaration of function 'fseeko' is invalid in C99 [-Wimplicit-function-declaration]
    } else if (fseeko(state.log_fp, -3, SEEK_END) == 0) {
               ^
1 warning generated.
./auth/passwd.c:85:22: warning: implicit declaration of function 'crypt' is invalid in C99 [-Wimplicit-function-declaration]
    epass = (char *) crypt(pass, pw_epasswd);
                     ^
1 warning generated.
./logging.c:825:69: warning: 'open' has superfluous mode bits; missing O_CREAT? [-Wuser-defined-warnings]
    fd = open(_PATH_DEVNULL, O_RDWR, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
                                                                    ^
/home/user/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/bits/fortify/fcntl.h:76:9: note: from 'diagnose_if' attribute on 'open':
        __clang_warning_if(!__open_modes_useful(flags) && modes,
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/user/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/sys/cdefs.h:135:54: note: expanded from macro '__clang_warning_if'
#define __clang_warning_if(cond, msg) __attribute__((diagnose_if(cond, msg, "warning")))
                                                     ^           ~~~~
1 warning generated.
In file included from ./match_command.c:39:
../../include/compat/glob.h:72:1: error: unknown type name '__dso_public'
__dso_public int  sudo_glob(const char *, int, int (*)(const char *, int), glob_t *);
^
../../include/compat/glob.h:73:1: error: unknown type name '__dso_public'
__dso_public void sudo_globfree(glob_t *);
^
2 errors generated.
make[1]: *** [Makefile:1822: match_command.lo] Error 1
make: *** [Makefile:108: all] Error 2
Comment 1 Todd C. Miller 2020-09-17 15:24:27 MDT
Please try with sudo 1.9.3b2, https://www.sudo.ws/dist/beta/sudo-1.9.3b2.tar.gz
Comment 2 Ivan Farkov 2020-09-17 16:16:22 MDT
Thank you for your interest.
With sudo-1.9.3b2.tar.gz i got this (I'm new to compiling using Linux and I'm not sure if this is a sudo/configure bug, sorry) :

configure: WARNING: using cross tools not prefixed with host triplet
configure: WARNING: Replacing missing/broken (v)snprintf() with sudo's version.
./sudo_debug.c:169:75: warning: 'open' has superfluous mode bits; missing O_CREAT? [-Wuser-defined-warnings]
    output->fd = open(output->filename, O_WRONLY|O_APPEND, S_IRUSR|S_IWUSR);
                                                                          ^
/home/user/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/bits/fortify/fcntl.h:76:9: note: from 'diagnose_if' attribute on 'open':
        __clang_warning_if(!__open_modes_useful(flags) && modes,
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/user/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/sys/cdefs.h:135:54: note: expanded from macro '__clang_warning_if'
#define __clang_warning_if(cond, msg) __attribute__((diagnose_if(cond, msg, "warning")))
                                                     ^           ~~~~
1 warning generated.
./iolog_fileio.c:701:8: warning: implicit declaration of function 'fseeko' is invalid in C99 [-Wimplicit-function-declaration]
        ret = fseeko(iol->fd.f, offset, whence);
              ^
1 warning generated.
./eventlog.c:630:16: warning: implicit declaration of function 'fseeko' is invalid in C99 [-Wimplicit-function-declaration]
    } else if (fseeko(fp, -3, SEEK_END) == 0) {
               ^
1 warning generated.
./audit_json.c:384:16: warning: implicit declaration of function 'fseeko' is invalid in C99 [-Wimplicit-function-declaration]
    } else if (fseeko(state.log_fp, -3, SEEK_END) == 0) {
               ^
1 warning generated.
./auth/passwd.c:85:22: warning: implicit declaration of function 'crypt' is invalid in C99 [-Wimplicit-function-declaration]
    epass = (char *) crypt(pass, pw_epasswd);
                     ^
1 warning generated.
./logging.c:824:69: warning: 'open' has superfluous mode bits; missing O_CREAT? [-Wuser-defined-warnings]
    fd = open(_PATH_DEVNULL, O_RDWR, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
                                                                    ^
/home/user/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/bits/fortify/fcntl.h:76:9: note: from 'diagnose_if' attribute on 'open':
        __clang_warning_if(!__open_modes_useful(flags) && modes,
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/user/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/sys/cdefs.h:135:54: note: expanded from macro '__clang_warning_if'
#define __clang_warning_if(cond, msg) __attribute__((diagnose_if(cond, msg, "warning")))
                                                     ^           ~~~~
1 warning generated.
./system_group.c:98:2: warning: implicit declaration of function 'setgrent' is invalid in C99 [-Wimplicit-function-declaration]
        setgrent();
        ^
./system_group.c:107:2: warning: implicit declaration of function 'endgrent' is invalid in C99 [-Wimplicit-function-declaration]
        endgrent();
        ^
2 warnings generated.
./limits.c:321:19: warning: result of comparison of constant 4611686018427387903 with expression of type '__kernel_ulong_t' (aka 'unsigned long') is always false [-Wtautological-constant-out-of-range-compare]
                if (rl.rlim_cur > LLONG_MAX / 2)
                    ~~~~~~~~~~~ ^ ~~~~~~~~~~~~~
1 warning generated.
./sudo.c:367:71: warning: 'open' has superfluous mode bits; missing O_CREAT? [-Wuser-defined-warnings]
        devnull = open(_PATH_DEVNULL, O_RDWR, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
                                                                             ^
/home/user/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/bits/fortify/fcntl.h:76:9: note: from 'diagnose_if' attribute on 'open':
        __clang_warning_if(!__open_modes_useful(flags) && modes,
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/user/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/sys/cdefs.h:135:54: note: expanded from macro '__clang_warning_if'
#define __clang_warning_if(cond, msg) __attribute__((diagnose_if(cond, msg, "warning")))
                                                     ^           ~~~~
1 warning generated.
./sudo_edit.c:118:36: error: use of undeclared identifier 'AT_EACCESS'
    rc = faccessat(dfd, ".", W_OK, AT_EACCESS);
                                   ^
1 error generated.
make[1]: *** [Makefile:702: sudo_edit.o] Error 1
make: *** [Makefile:108: all] Error 2
Comment 3 Ivan Farkov 2020-09-17 16:30:30 MDT
As a workaround I set AT_EACCESS=0, and got this error 
(I don't include warnings, if they can be helpful, just tell me and I'll add them):

utmp.o:utmp.c:function utmp_slot: error: undefined reference to 'ttyslot'
utmp.o:utmp.c:function utmp_fill: error: undefined reference to 'utmp_setid'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Makefile:174: sudo] Error 1
make: *** [Makefile:108: all] Error 2
Comment 4 Todd C. Miller 2020-09-17 18:12:36 MDT
It doesn't looks like Android provides a way to update the utmp file.  Sudo assumes it is being run on a Unix system, which Android barely qualifies as.  I could add a configure check for ttyslot() and simply skip the utmp updating code if neither the POSIX utmp update functions nor ttyslot() are present.

It also seems like your header files don't match the libraries you are trying to link with.  Those warnings and errors really sound like a library and header mismatch.  As far as I can tell, the bionic headers should have prototypes for the functions.  It looks like AT_EACCESS is not supported with faccessat() so you should probably just tell configure you have no faccessat() function by setting ac_cv_func_faccessat=no.

I'm not sure that Android is really capable of running sudo but I'd be interested in hearing whether or not you get it working.
Comment 5 Todd C. Miller 2020-09-17 21:38:55 MDT
The following commits should fixed the undefined symbol errors:
https://www.sudo.ws/repos/sudo/rev/69fe5b8426cd
https://www.sudo.ws/repos/sudo/rev/18604919a023
Comment 6 Ivan Farkov 2020-09-18 05:05:34 MDT
here https://www.sudo.ws/repos/sudo/rev/69fe5b8426cd you have a little typo ;)

 retun -1;
Comment 7 Ivan Farkov 2020-09-18 06:01:50 MDT
(In reply to Todd C. Miller from comment #4)

> It also seems like your header files don't match the libraries you
> are trying to link with.  Those warnings and errors really sound
> like a library and header mismatch.  As far as I can tell, the
> bionic headers should have prototypes for the functions.

Thank you for the info!
In case it might interest you (it may well be that not), when I compile (with _NO_ cross) with CC=clang I got this only this in stderr:
libtool: warning: relinking 'audit_json.la'
libtool: warning: relinking 'group_file.la'
libtool: warning: relinking 'sample_approval.la'
libtool: warning: relinking 'sudoers.la'
libtool: warning: relinking 'system_group.la'
But when I use clang from NDK release android-ndk-r21d-linux-x86_64.zip (the latest one at the moment), I get that "bunch" of warnings like in my original post. Not sure, but there may be a problem in the NDK. Thanks anyway for explaining the warnings.
Comment 8 Ivan Farkov 2020-09-18 06:19:46 MDT
(In reply to Todd C. Miller from comment #5)
> The following commits should fixed the undefined symbol errors:
> https://www.sudo.ws/repos/sudo/rev/69fe5b8426cd
> https://www.sudo.ws/repos/sudo/rev/18604919a023

I've tried using the current https://github.com/sudo-project/sudo/archive/master.zip (with your fixes).
It cross-compiled successfully. Yep, on android i got [[CANNOT LINK EXECUTABLE "./sudo": library "libsudo_util.so" not found]], but sudo is started. Thank you for your help.

Now I added "--disable-shared --disable-shared-libutil --enable-static-sudoers" to the ./configure call and got this error:

../plugins/sudoers/.libs/sudoers.a(passwd.o):passwd.c:function sudo_passwd_verify: error: undefined reference to 'crypt'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Makefile:174: sudo] Error 1
make: *** [Makefile:108: all] Error 2
Comment 9 Todd C. Miller 2020-09-18 06:23:57 MDT
bionic apparently does not implement crypt(); I'm not sure how you would verify a password on Android.
Comment 10 Todd C. Miller 2020-09-18 08:52:58 MDT
You should be able to link sudo after the following commit:
https://www.sudo.ws/repos/sudo/rev/aed39197f364

But I'm not sure you'll be able to actually authenticate a user.
Comment 11 Todd C. Miller 2020-09-21 08:29:05 MDT
Closing this now that the link errors are resolved.  You can either reopen this bug or create a new one for other Android-related issues.
Comment 12 Ivan Farkov 2020-09-23 05:30:05 MDT
> You should be able to link sudo after the following commit

Yes, sudo for android was built successfully, thank you for the help!


> I'm not sure that Android is really capable of running sudo but I'd
> be interested in hearing whether or not you get it working.

Well, "./sudo -h" runs on my rooted samsung android 10. :)
But unfortunately I still can't get "./sudo echo 1" to work as expected:
  1. When I run as "shell" user, I get "effective uid is not 0, is ./sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?" (I tried "mount -o rw, suid, remount /", didn't help).
  2. When I run as "root" user (after "su" command), I get "Segmentation fault" message.

I am sorry for the delay. I felt like I was about to get sudo to work on android.

I will continue to find out if the problem is my phone or my poor knowledge of Linux. The latter is very likely.
But while there are still problems in the absence of a variety of Linux utilities. And I'm trying, with varying success, to compile them for android.