Bug 22361 - Can not compile with solaris getpwnam_r()
Summary: Can not compile with solaris getpwnam_r()
Status: RESOLVED FIXED
Alias: None
Product: ConsoleKit
Classification: Unclassified
Component: PAM module (show other bugs)
Version: unspecified
Hardware: All Solaris
: medium critical
Assignee: william.jon.mccann
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-19 01:16 UTC by Halton Huo
Modified: 2009-07-20 13:31 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
no difference for getpwnam_r() between Solaris and others (936 bytes, patch)
2009-06-19 01:21 UTC, Halton Huo
Details | Splinter Review

Description Halton Huo 2009-06-19 01:16:23 UTC
When I try to build master code on latest Solaris build snv_117, I found it build with following error:

 /opt/SUNWspro/bin/cc -DHAVE_CONFIG_H -I. -I.. -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I../libck-connector -I/usr/sfw/include -i -g -xstrconst -xpentium -mr -xregs=no%frameptr -I/usr/sfw/include -DANSICPP -c pam-ck-connector.c  -KPIC -DPIC -o .libs/pam-ck-connector.o
"pam-ck-connector.c", line 201: prototype mismatch: 4 args passed, 5 expected
[...]
cc: acomp failed for pam-ck-connector.c
Comment 1 Halton Huo 2009-06-19 01:21:33 UTC
Created attachment 26949 [details] [review]
no difference for getpwnam_r() between Solaris and others

Checked solaris pwd.h, uses POSIX getpwnam_r().
    151 #if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
    152 
    153 #ifdef __PRAGMA_REDEFINE_EXTNAME
    154 #pragma redefine_extname getpwuid_r __posix_getpwuid_r
    155 #pragma redefine_extname getpwnam_r __posix_getpwnam_r
    156 extern int getpwuid_r(uid_t, struct passwd *, char *, int, struct passwd **);
    157 extern int getpwnam_r(const char *, struct passwd *, char *,
    158 							int, struct passwd **);

It turns out x11 on Solaris define _POSIX_PTHREAD_SEMANTICS
$pkg-config --cflags x11
-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -I/usr/X11/include

So, we need not "#ifdef __sun .. #else" code in pam-ck-connector.c
static uid_t
_util_name_to_uid(
[...]
#ifdef __sun
        pwdp = getpwnam_r (username, &pwd, buf, bufsize);
        if (pwdp == NULL) {
                goto out;
        }
#else
        rc = getpwnam_r (username, &pwd, buf, bufsize, &pwdp);
        if (rc != 0 || pwdp == NULL) {
                goto out;
        }
#endif

So the patch is easy to come.
Comment 2 Halton Huo 2009-06-19 01:24:39 UTC
This patch is actually revert the change for close bug #18173, the 6. change on comment #2.
Comment 3 Ray Strode 2009-07-20 13:31:28 UTC
Committed


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.