Samba 4 diffs for building under HP-UX 11.11 (in gcc environment)
Don McCall
donmccall1 at yahoo.com
Wed Aug 17 12:31:27 GMT 2005
Hi All,
I got inspired after the CIFS conference, and Tridge's talk about the
Samba 4 test suite. So I'm working with our lab to start moving over
from our internal test suite to one build on (or at least
incorporating) the Samba 4 test suite.
In order to do this, I had to make some code changes so that Samba 4
would build (under gcc) on HP-UX.
I ran it past Andrew B. and he said to go ahead and post it to the list, with the comment that the heimdal change really should be made upstream or in the lorikeet-heimdal branch...
Can I ask someone to check this in, so other folks trying to build on HP-UX 11.11 will succeed (and so my build farm machine has a chance of working ;-)
Thanks,
Don McCall
**************************************************************************************************
Index: lib/unix_privs.c
===================================================================
--- lib/unix_privs.c (revision 9314)
+++ lib/unix_privs.c (working copy)
@@ -48,8 +48,13 @@
static int privileges_destructor(void *ptr) {
struct saved_state *s = ptr;
+#if defined(HAVE_SETEUID)
if (geteuid() != s->uid &&
seteuid(s->uid) != 0) {
+#elif defined(HAVE_SETRESUID) && !defined(HAVE_SETEUID)
+ if (geteuid() != s->uid &&
+ setresuid(-1,s->uid,-1) != 0) {
+#endif
smb_panic("Failed to restore privileges");
}
return 0;
@@ -62,7 +67,11 @@
if (!s) return NULL;
s->uid = geteuid();
if (s->uid != 0) {
+#if defined(HAVE_SETEUID)
seteuid(0);
+#elif defined(HAVE_SETRESUID) && !defined(HAVE_SETEUID)
+ setresuid(-1,0,-1);
+#endif
}
talloc_set_destructor(s, privileges_destructor);
return s;
Index: lib/system.c
===================================================================
--- lib/system.c (revision 9314)
+++ lib/system.c (working copy)
@@ -234,4 +234,15 @@
in2.addr = in.s_addr;
return in2;
}
+/**********************************************************************
+/
+/**** A wrapper for __strtoll() - HP-UX doesnt have a strtoll()
routine
+*/
+/**********************************************************************
+*/ #if !defined(HAVE_STRTOLL) && defined(HAVE___STRTOLL) #include
+<inttypes.h> long long strtoll(const char *nptr, char ** endptr, int
+base) {
+ return __strtoll(nptr,endptr,base); } #endif
+
Index: build/m4/rewrite.m4
===================================================================
--- build/m4/rewrite.m4 (revision 9314)
+++ build/m4/rewrite.m4 (working copy)
@@ -122,6 +122,9 @@
AC_FUNC_MEMCMP
AC_CHECK_FUNCS(dlopen dlsym dlerror waitpid getcwd strdup strndup
strnlen strtoul strtoull strtouq strerror chroot)
+# checking for some functions that HPUX doesn't have, and replacements
+AC_CHECK_FUNCS(strtoll __strtoll seteuid setresuid setegid setresgid)
#
+end hpux function check
AC_CHECK_FUNCS(bzero memset strlcpy strlcat) AC_CHECK_FUNCS(memmove
vsnprintf snprintf asprintf vasprintf setsid pipe crypt16 getauthuid)
AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction innetgr
setnetgrent getnetgrent endnetgrent)
Index: ntvfs/unixuid/vfs_unixuid.c
===================================================================
--- ntvfs/unixuid/vfs_unixuid.c (revision 9314)
+++ ntvfs/unixuid/vfs_unixuid.c (working copy)
@@ -78,15 +78,27 @@
*/
static NTSTATUS set_unix_security(struct unix_sec_ctx *sec) {
+#if defined(HAVE_SETEUID)
seteuid(0);
+#elif defined(HAVE_SETRESUID) && !defined(HAVE_SETEUID)
+ setresuid(-1,0,-1);
+#endif
if (setgroups(sec->ngroups, sec->groups) != 0) {
return NT_STATUS_ACCESS_DENIED;
}
+#if defined(HAVE_SETEGID)
if (setegid(sec->gid) != 0) {
+#elif defined(HAVE_SETRESGID) && !defined(HAVE_SETEGID)
+ if (setresgid(-1,sec->gid,-1) != 0) {
+#endif
return NT_STATUS_ACCESS_DENIED;
}
+#if defined(HAVE_SETEUID)
if (seteuid(sec->uid) != 0) {
+#elif defined(HAVE_SETRESUID) && !defined(HAVE_SETEUID)
+ if (setresuid(-1,sec->uid,-1) != 0) {
+#endif
return NT_STATUS_ACCESS_DENIED;
}
return NT_STATUS_OK;
Index: heimdal/lib/roken/roken.h
===================================================================
--- heimdal/lib/roken/roken.h (revision 9314)
+++ heimdal/lib/roken/roken.h (working copy)
@@ -287,12 +287,16 @@
const char * ROKEN_LIB_FUNCTION get_default_username (void);
-#ifndef HAVE_SETEUID
+#if defined(HAVE_SETEUID)
int ROKEN_LIB_FUNCTION seteuid(uid_t);
+#elif !defined(HAVE_SETEUID) && defined(HAVE_SETRESUID) int
+ROKEN_LIB_FUNCTION setresuid(uid_t,uid_t,uid_t);
#endif
-#ifndef HAVE_SETEGID
+#if defined(HAVE_SETEGID)
int ROKEN_LIB_FUNCTION setegid(gid_t);
+#elif (!defined(HAVE_SETEGID) && defined(HAVE_SETRESGID)) int
+ROKEN_LIB_FUNCTION setresgid(gid_t,gid_t,gid_t);
#endif
#ifndef HAVE_LSTAT
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the samba-technical
mailing list