* add in David Lee's utmp patch (defaults to on if available)
authorGerald Carter <jerry@samba.org>
Fri, 6 Jun 2003 22:33:43 +0000 (22:33 +0000)
committerGerald Carter <jerry@samba.org>
Fri, 6 Jun 2003 22:33:43 +0000 (22:33 +0000)
* one more try at fixing builds when --with-ldap=no
(This used to be commit b516ab7bdef6b6b2b7f0df8966dbd4c329f46a92)

source3/configure.in
source3/param/loadparm.c
source3/smbd/session.c
source3/smbd/utmp.c

index 6405138185620a9c95801a89c9250c7bb383334b..a90721c152b522bc0d3fc5b825ba9cce5ee1ac2f 100644 (file)
@@ -1367,6 +1367,9 @@ if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
     AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
 fi
 
+##############
+# Check utmp details, but only if our OS offers utmp.h
+if test x"$ac_cv_header_utmp_h" = x"yes"; then
 dnl  utmp and utmpx come in many flavours
 dnl  We need to check for many of them
 dnl  But we don't need to do each and every one, because our code uses
@@ -1484,6 +1487,9 @@ if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
     AC_DEFINE(HAVE_UX_UT_SYSLEN,1,[Whether the utmpx struct has a property ut_syslen])
 fi 
 
+fi
+# end utmp details
+
 
 ICONV_LOCATION=standard
 LOOK_DIRS="/usr /usr/local /sw"
@@ -2308,6 +2314,7 @@ AC_ARG_WITH(ldap,
 
 AC_MSG_RESULT($with_ldap_support)
 
+SMBLDAP=""
 if test x"$with_ldap_support" = x"yes"; then
   ac_save_LIBS="$LIBS"
   LIBS=""
@@ -2325,13 +2332,11 @@ if test x"$with_ldap_support" = x"yes"; then
            AC_CHECK_LIB(ldap, ldap_domain2hostlist, [
              AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
              AC_CHECK_HEADERS([ldap.h lber.h], 
-                 [default_static_modules="$default_static_modules pdb_ldap idmap_ldap"])
+                 [default_static_modules="$default_static_modules pdb_ldap idmap_ldap";
+                  SMBLDAP="lib/smbldap.o"])
            ])
         ])
 
-       ## we have ldap so build the list of files for the generic samba ldap library
-       SMBLDAP="lib/smbldap.o"
-
        ########################################################
        # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
        # Check found in pam_ldap 145.
@@ -2879,20 +2884,36 @@ fi
 # check for experimental utmp accounting
 
 AC_MSG_CHECKING(whether to support utmp accounting)
+WITH_UTMP=yes
 AC_ARG_WITH(utmp,
-[  --with-utmp             Include experimental utmp accounting (default=no)],
+[  --with-utmp             Include utmp accounting (default, if supported by OS)],
 [ case "$withval" in
-  yes)
-    AC_MSG_RESULT(yes)
-    AC_DEFINE(WITH_UTMP,1,[Whether to include experimental utmp accounting])
-    ;;
+  no)
+               WITH_UTMP=no
+               ;;
   *)
-    AC_MSG_RESULT(no)
-    ;;
+               WITH_UTMP=yes
+                ;;
   esac ],
-  AC_MSG_RESULT(no)
 )
 
+# utmp requires utmp.h
+# Note similar check earlier, when checking utmp details.
+
+if test x"$WITH_UTMP" = x"yes" -a x"$ac_cv_header_utmp_h" = x"no"; then
+       utmp_no_reason=", no utmp.h on $host_os"
+       WITH_UTMP=no
+fi
+
+# Display test results
+
+if test x"$WITH_UTMP" = x"yes"; then
+        AC_MSG_RESULT(yes)
+       AC_DEFINE(WITH_UTMP,1,[Whether to include experimental utmp accounting])
+else
+        AC_MSG_RESULT(no$utmp_no_reason)
+fi
+
 #################################################
 # choose native language(s) of man pages
 AC_MSG_CHECKING(chosen man pages' language(s))
index a5e9b1467f282764944547870282beb823cbb47b..49f0bbd2a4d8e62e21c04c7a8f800f64c5fb70e4 100644 (file)
@@ -158,11 +158,9 @@ typedef struct
        char *szAbortShutdownScript;
        char *szWINSHook;
        char *szWINSPartners;
-#ifdef WITH_UTMP
        char *szUtmpDir;
        char *szWtmpDir;
        BOOL bUtmp;
-#endif
        char *szSourceEnv;
        char *szIdmapUID;
        char *szIdmapGID;
@@ -1575,11 +1573,9 @@ FN_GLOBAL_STRING(lp_lockdir, &Globals.szLockDir)
 FN_GLOBAL_STRING(lp_piddir, &Globals.szPidDir)
 FN_GLOBAL_STRING(lp_mangling_method, &Globals.szManglingMethod)
 FN_GLOBAL_INTEGER(lp_mangle_prefix, &Globals.mangle_prefix)
-#ifdef WITH_UTMP
 FN_GLOBAL_STRING(lp_utmpdir, &Globals.szUtmpDir)
 FN_GLOBAL_STRING(lp_wtmpdir, &Globals.szWtmpDir)
 FN_GLOBAL_BOOL(lp_utmp, &Globals.bUtmp)
-#endif
 FN_GLOBAL_STRING(lp_rootdir, &Globals.szRootdir)
 FN_GLOBAL_STRING(lp_source_environment, &Globals.szSourceEnv)
 FN_GLOBAL_STRING(lp_defaultservice, &Globals.szDefaultService)
index b7f3bc43e75ae5a1cae707f89bf63996d3f80d89..4d8826d3323d3f4eca301f308dfb07903c4efe00 100644 (file)
@@ -66,7 +66,6 @@ BOOL session_claim(user_struct *vuser)
        data.dptr = NULL;
        data.dsize = 0;
 
-#if WITH_UTMP
        if (lp_utmp()) {
                for (i=1;i<MAX_SESSION_ID;i++) {
                        slprintf(keystr, sizeof(keystr)-1, "ID/%d", i);
@@ -84,7 +83,6 @@ BOOL session_claim(user_struct *vuser)
                slprintf(sessionid.id_str, sizeof(sessionid.id_str)-1, SESSION_UTMP_TEMPLATE, i);
                tdb_store_flag = TDB_MODIFY;
        } else
-#endif
        {
                slprintf(keystr, sizeof(keystr)-1, "ID/%lu/%u", 
                         (long unsigned int)sys_getpid(), 
@@ -137,13 +135,11 @@ BOOL session_claim(user_struct *vuser)
                return False;
        }
 
-#if WITH_UTMP  
        if (lp_utmp()) {
                sys_utmp_claim(sessionid.username, sessionid.hostname, 
                               client_ip,
                               sessionid.id_str, sessionid.id_num);
        }
-#endif
 
        vuser->session_keystr = strdup(keystr);
        if (!vuser->session_keystr) {
@@ -181,13 +177,11 @@ void session_yield(user_struct *vuser)
 
        SAFE_FREE(dbuf.dptr);
 
-#if WITH_UTMP  
        if (lp_utmp()) {
                sys_utmp_yield(sessionid.username, sessionid.hostname, 
                               client_ip,
                               sessionid.id_str, sessionid.id_num);
        }
-#endif
 
        smb_pam_close_session(sessionid.username, sessionid.id_str, sessionid.hostname);
 
index 2c5a1abc8245036ef7b42dfdc86b5f3d085f9c82..9833a11f2d0fb4f7d06dc89f4b032076a3836dce 100644 (file)
@@ -21,8 +21,6 @@
 
 #include "includes.h"
 
-#ifdef WITH_UTMP
-
 /****************************************************************************
 Reflect connection status in utmp/wtmp files.
        T.D.Lee@durham.ac.uk  September 1999
@@ -110,6 +108,23 @@ Notes:
 
 ****************************************************************************/
 
+#ifndef WITH_UTMP
+/*
+ * Not WITH_UTMP?  Simply supply dummy routines.
+ */
+
+void sys_utmp_claim(const char *username, const char *hostname, 
+                   struct in_addr *ipaddr,
+                   const char *id_str, int id_num)
+{}
+
+void sys_utmp_yield(const char *username, const char *hostname, 
+                   struct in_addr *ipaddr,
+                   const char *id_str, int id_num)
+{}
+
+#else /* WITH_UTMP */
+
 #include <utmp.h>
 
 #ifdef HAVE_UTMPX_H
@@ -571,6 +586,4 @@ void sys_utmp_claim(const char *username, const char *hostname,
        sys_utmp_update(&u, hostname, True);
 }
 
-#else /* WITH_UTMP */
- void dummy_utmp(void) {}
-#endif
+#endif /* WITH_UTMP */