samba's glibc issues: the patch?

Paul PELaufer at csupomona.edu
Thu Feb 11 02:59:09 GMT 1999


Hello everyone,
	I have been collecting the various Glibc unofficial patches for
Samba that have been floating around on linux-kernel and other lists for
quite some time.  Through messing around with these different patches I
have familiarized myself a little with the Samba code.

	Right now there are just a few things that need to be done to get
Samba to work properly with Glibc 2.1 stable. This is important since many
distros will soon be using this version of Glibc. I have attached a
patch for Samba 2.0.2 that includes all the changes outlined below. If you
would like me to submit each of these separately, I can do that, too.

	First, smbumount still has one reference to "uid_t" that needs to
be changed to "__kernel_uid_t". This has been done with every other
occurance of uid_t in the smbmount utils, so I don't see why it shouldn't
happen here.

	Second, source/printing/printing.c uses the strncat() function. In
Glibc 2.1 this is a macro that references strcat(). I'm sure you can see
what the problem is ;). I have swapped strncat with safe_strcat, which
seems to be consistant with the rest of the Samba code.

	Third, smbwrapper complains about NULL not being defined. This is
easy to fix. (Andreas Jaeger brought this to my attention.)

	Fourth, -D_LARGEFILE64_SOURCE needs to be defined in order to
enable LFS with Glibc. I have a configure test (written by Andreas Jaeger)
to check if this is needed on linux and hurd systems.

	Fifth and finally, smbmount uses NR_OPEN. This is #undefed by
the Glibc limits.h header file after including linux/limits.h if NR_OPEN
was not previously defined. I solved this by including linux/limits.h
before includes.h in smbmount.c. This shouldn't be a problem because
smbmount is Linux only anyway. The other solution would be to get rid of
the close_our_files() function in smbmount.c, which is currently not used.
The problems with automount seem to stem from this function, too (ie: it
closes all of the file handles that smbmount inherits from automount . . .
).

Thanks,
Paul Laufer

On Wed, 10 Feb 1999, Andy Bakun wrote:

> In
> 
>      http://www.samba.org/listproc/samba-technical/2698.html
> 
> Paul mentions that he can provide a patch for glibc issues with samba,
> specificly the strncpy being a macro that expands to strcpy which causes
> compilation to die with an error.  Was this patch ever submitted to
> anyone?  Where can I get it from?
> 
> Andy.
> 
> 
-------------- next part --------------
diff -urN samba-2.0.2.orig/source/client/smbmount.c samba-2.0.2/source/client/smbmount.c
--- samba-2.0.2.orig/source/client/smbmount.c	Fri Feb  5 18:17:45 1999
+++ samba-2.0.2/source/client/smbmount.c	Tue Feb  9 18:28:19 1999
@@ -27,6 +27,7 @@
 #error this code will only compile on versions of linux after 2.1.70
 #endif
 
+#include <linux/limits.h>
 #include "includes.h"
 
 #include <asm/types.h>
diff -urN samba-2.0.2.orig/source/client/smbumount.c samba-2.0.2/source/client/smbumount.c
--- samba-2.0.2.orig/source/client/smbumount.c	Fri Feb  5 18:17:45 1999
+++ samba-2.0.2/source/client/smbumount.c	Tue Feb  9 18:28:19 1999
@@ -35,7 +35,7 @@
 umount_ok(const char *mount_point)
 {
         int fid = open(mount_point, O_RDONLY, 0);
-        uid_t mount_uid;
+        __kernel_uid_t mount_uid;
 
         if (fid == -1) {
                 fprintf(stderr, "Could not open %s: %s\n",
diff -urN samba-2.0.2.orig/source/configure samba-2.0.2/source/configure
--- samba-2.0.2.orig/source/configure	Sat Feb  6 14:51:52 1999
+++ samba-2.0.2/source/configure	Tue Feb  9 18:32:31 1999
@@ -7,6 +7,9 @@
 # This configure script is free software; the Free Software Foundation
 # gives unlimited permission to copy, distribute and modify it.
 
+echo -e "\nPlease run autoconf first.\n"
+exit 0
+
 # Defaults:
 ac_help=
 ac_default_prefix=/usr/local
diff -urN samba-2.0.2.orig/source/configure.in samba-2.0.2/source/configure.in
--- samba-2.0.2.orig/source/configure.in	Sat Feb  6 14:51:52 1999
+++ samba-2.0.2/source/configure.in	Tue Feb  9 18:28:28 1999
@@ -132,6 +132,28 @@
       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
       fi
     ;;
+#
+# Tests needed for glibc 2.1 large file support.
+# 
+    *linux*|*hurd*)
+        AC_MSG_CHECKING([for LFS support])
+        old_CPPFLAGS="$CPPFLAGS"
+        CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
+        AC_TRY_RUN([
+#include <unistd.h>
+main () {
+#if _LFS64_LARGEFILE == 1
+exit(0);
+#else
+exit(1);
+#endif
+}], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
+        CPPFLAGS="$old_CPPFLAGS"
+        if test x$GLIBC_LFS_SUPPORT = xyes ; then
+          CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
+        fi
+      AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
+    ;;
 esac
 
 AC_INLINE
diff -urN samba-2.0.2.orig/source/printing/printing.c samba-2.0.2/source/printing/printing.c
--- samba-2.0.2.orig/source/printing/printing.c	Mon Dec 14 17:21:09 1998
+++ samba-2.0.2/source/printing/printing.c	Tue Feb  9 18:28:19 1999
@@ -263,8 +263,8 @@
     bufsize = sizeof(buf->file) - strlen(buf->file) - 1;
 
     for (i = (FILETOK + 1); i < TOTALTOK; i++) {
-      strncat(buf->file," ",bufsize);
-      strncat(buf->file,tok[i],bufsize - 1);
+      safe_strcat(buf->file," ",bufsize);
+      safe_strcat(buf->file,tok[i],bufsize - 1);
       bufsize = sizeof(buf->file) - strlen(buf->file) - 1;
       if (bufsize <= 0) {
         break;
@@ -378,8 +378,8 @@
     bufsize = sizeof(buf->file) - strlen(buf->file) - 1;
 
     for (i = (LPRNG_FILETOK + 1); i < LPRNG_TOTALTOK; i++) {
-      strncat(buf->file," ",bufsize);
-      strncat(buf->file,tokarr[i],bufsize - 1);
+      safe_strcat(buf->file," ",bufsize);
+      safe_strcat(buf->file,tokarr[i],bufsize - 1);
       bufsize = sizeof(buf->file) - strlen(buf->file) - 1;
       if (bufsize <= 0) {
         break;
diff -urN samba-2.0.2.orig/source/smbwrapper/wrapped.c samba-2.0.2/source/smbwrapper/wrapped.c
--- samba-2.0.2.orig/source/smbwrapper/wrapped.c	Fri Oct 23 23:36:22 1998
+++ samba-2.0.2/source/smbwrapper/wrapped.c	Tue Feb  9 18:28:28 1999
@@ -30,6 +30,10 @@
 #include <errno.h>
 #include "realcalls.h"
 
+#ifndef NULL
+# define NULL ((void *)0)
+#endif
+
  int open(char *name, int flags, mode_t mode)
 {
 	if (smbw_path(name)) {


More information about the samba-technical mailing list