Diff to make smb tools work on glibc systems. (fwd)

Krzysztof G. Baranowski kgb w manjak.knm.org.pl
Pią, 28 Sie 1998, 22:42:17 CEST


Moze sie przydac....

Kris
-- 
Krzysztof G. Baranowski - Prezes Klubu Nieszkodliwych Manjaków
"Smith & Wesson - The original point and click interface..."
http://www.knm.org.pl/              <prezes w manjak.knm.org.pl>

---------- Forwarded message ----------
Date: Thu, 27 Aug 1998 19:53:39 -0400
From: Pal-Kristian Engstad <engstad w intermetrics.com>
Subject: Diff to make smb tools work on glibc systems.

There's a lot of trouble getting glibc working with ksmbfs
tools. Following is a diff which worked for me:

diff -u3 samba-1.9.18p8/source/smbmnt.c samba-1.9.18p8-new/source/smbmnt.c
- --- samba-1.9.18p8/source/smbmnt.c	Mon Jan 26 15:05:46 1998
+++ samba-1.9.18p8-new/source/smbmnt.c	Thu Aug 27 18:24:35 1998
@@ -3,6 +3,8 @@
  *
  *  Copyright (C) 1995-1998 by Paal-Kr. Engstad and Volker Lendecke
  *
+ *  History:
+ *      Fixing glibc troubles by Pal-Kristian Engstad, Aug 27, 1998.
  */
 
 #include <stdio.h>
@@ -10,28 +12,26 @@
 #include <signal.h>
 #include <pwd.h>
 #include <grp.h>
- -#include <sys/socket.h>
- -#include <sys/param.h>
- -#include <netinet/in.h>
 #include <netdb.h>
- -#include <sys/stat.h>
- -#include <sys/types.h>
- -/* #include <sys/wait.h> */  /* generates a warning here */
- -extern pid_t waitpid(pid_t, int *, int);
- -#include <sys/errno.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
 #include <ctype.h>
 #include <stdlib.h>
- -#include <sys/mount.h>
 #include <mntent.h>
 
- -#include <linux/fs.h>
- -#include <linux/smb.h>
- -#include <linux/smb_mount.h>
- -
 #include <asm/unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+   
+#include <sys/socket.h>
+#include <sys/param.h>
+#include <sys/errno.h>
+#include <sys/mount.h>
+#include <netinet/in.h>
+
+#undef _LINUX_TYPES_H
+#include <linux/smb_mount.h>
 
 static char *progname;
 
@@ -146,9 +146,8 @@
                 return -1;
         }
 	
- -        if (   (getuid() != 0)
- -            && (   (getuid() != st->st_uid)
- -                || ((st->st_mode & S_IRWXU) != S_IRWXU)))
+        if (getuid() != 0 && 
+            (getuid() != st->st_uid || (st->st_mode & S_IRWXU) != S_IRWXU))
         {
                 errno = EPERM;
                 return -1;
@@ -172,10 +171,10 @@
 
 	memset(&data, 0, sizeof(struct smb_mount_data));
 
- -	if (   (argc == 2)
- -	       && (argv[1][0] == '-')
- -	       && (argv[1][1] == 'h')
- -	       && (argv[1][2] == '\0'))
+	if (argc == 2 &&
+            argv[1][0] == '-' &&
+            argv[1][1] == 'h' &&
+            argv[1][2] == '\0')
 	{
 		help();
 		return 0;
@@ -260,16 +259,17 @@
 		return -1;
 	}
 	
- -        if ((fd = open(MOUNTED"~", O_RDWR|O_CREAT|O_EXCL, 0600)) == -1)
+        /* Set the mount point in /etc/mtab. */
+        if ((fd = open(_PATH_MOUNTED "~", O_RDWR|O_CREAT|O_EXCL, 0600)) == -1)
         {
- -                fprintf(stderr, "Can't get "MOUNTED"~ lock file");
+                fprintf(stderr, "Can't get " _PATH_MOUNTED "~ lock file");
                 return 1;
         }
         close(fd);
 	
- -        if ((mtab = setmntent(MOUNTED, "a+")) == NULL)
+        if ((mtab = setmntent(_PATH_MOUNTED, "a+")) == NULL)
         {
- -                fprintf(stderr, "Can't open " MOUNTED);
+                fprintf(stderr, "Can't open " _PATH_MOUNTED);
                 return 1;
         }
 
@@ -280,14 +280,14 @@
         }
         if (fchmod(fileno(mtab), 0644) == -1)
         {
- -                fprintf(stderr, "Can't set perms on "MOUNTED);
+                fprintf(stderr, "Can't set perms on " _PATH_MOUNTED);
                 return 1;
         }
         endmntent(mtab);
 
- -        if (unlink(MOUNTED"~") == -1)
+        if (unlink(_PATH_MOUNTED "~") == -1)
         {
- -                fprintf(stderr, "Can't remove "MOUNTED"~");
+                fprintf(stderr, "Can't remove " _PATH_MOUNTED "~");
                 return 1;
         }
 
Only in samba-1.9.18p8-new/source/: smbmount.E
diff -u3 samba-1.9.18p8/source/smbmount.c samba-1.9.18p8-new/source/smbmount.c
- --- samba-1.9.18p8/source/smbmount.c	Tue May 12 21:46:57 1998
+++ samba-1.9.18p8-new/source/smbmount.c	Thu Aug 27 18:25:02 1998
@@ -19,18 +19,29 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+/*
+ *  History:
+ *      Fixing glibc troubles by Pal-Kristian Engstad, Aug 27, 1998.
+ */
+
+
 #ifdef SYSLOG
 #undef SYSLOG
 #endif
 
 #include <linux/version.h>
+
 #define LVERSION(major,minor,patch) (((((major)<<8)+(minor))<<8)+(patch))
 #if LINUX_VERSION_CODE < LVERSION(2,1,70)
 #error this code will only compile on versions of linux after 2.1.70
 #endif
 
 #include "includes.h"
+
+#undef _LINUX_TYPES_H
+#include <linux/smb_mount.h>
 #include <linux/smb_fs.h>
+
 static struct smb_conn_opt conn_options;
 
 #ifndef REGISTER
@@ -213,7 +224,7 @@
 }
 
 static void
- -usr1_handler(int x)
+usr1_handler(int c)
 {
 	return;
 }
Only in samba-1.9.18p8-new/source/: smbmount.e
diff -u3 samba-1.9.18p8/source/smbumount.c samba-1.9.18p8-new/source/smbumount.c
- --- samba-1.9.18p8/source/smbumount.c	Tue May 12 21:46:57 1998
+++ samba-1.9.18p8-new/source/smbumount.c	Thu Aug 27 18:24:25 1998
@@ -3,6 +3,8 @@
  *
  *  Copyright (C) 1995-1998 by Volker Lendecke
  *
+ *  History:
+ *      Fixing glibc troubles by Pal-Kristian Engstad, Aug 27, 1998.
  */
 
 #include <stdio.h>
@@ -28,9 +30,8 @@
 #include <mntent.h>
 
 #include <sys/ioctl.h>
- -#include <linux/fs.h>
- -#include <linux/smb.h>
- -#include <linux/smb_mount.h>
+
+#undef _LINUX_TYPES_H
 #include <linux/smb_fs.h>
 
 static char *progname;
@@ -92,7 +93,8 @@
 	if (realpath (path, canonical))
 		return canonical;
 
- -	pstrcpy (canonical, path);
+        /* Don't use pstrcpy, since this is safe (see above for check). */
+	strcpy (canonical, path);
 	return canonical;
 }
 
@@ -137,20 +139,20 @@
                 exit(1);
         }
 
- -        if ((fd = open(MOUNTED"~", O_RDWR|O_CREAT|O_EXCL, 0600)) == -1)
+        if ((fd = open(_PATH_MOUNTED "~", O_RDWR|O_CREAT|O_EXCL, 0600)) == -1)
         {
- -                fprintf(stderr, "Can't get "MOUNTED"~ lock file");
+                fprintf(stderr, "Can't get " _PATH_MOUNTED "~ lock file");
                 return 1;
         }
         close(fd);
 	
- -        if ((mtab = setmntent(MOUNTED, "r")) == NULL) {
- -                fprintf(stderr, "Can't open " MOUNTED ": %s\n",
+        if ((mtab = setmntent(_PATH_MOUNTED, "r")) == NULL) {
+                fprintf(stderr, "Can't open " _PATH_MOUNTED ": %s\n",
                         strerror(errno));
                 return 1;
         }
 
- -#define MOUNTED_TMP MOUNTED".tmp"
+#define MOUNTED_TMP _PATH_MOUNTED ".tmp"
 
         if ((new_mtab = setmntent(MOUNTED_TMP, "w")) == NULL) {
                 fprintf(stderr, "Can't open " MOUNTED_TMP ": %s\n",
@@ -175,15 +177,15 @@
 
         endmntent(new_mtab);
 
- -        if (rename(MOUNTED_TMP, MOUNTED) < 0) {
+        if (rename(MOUNTED_TMP, _PATH_MOUNTED) < 0) {
                 fprintf(stderr, "Cannot rename %s to %s: %s\n",
- -                        MOUNTED, MOUNTED_TMP, strerror(errno));
+                        _PATH_MOUNTED, MOUNTED_TMP, strerror(errno));
                 exit(1);
         }
 
- -        if (unlink(MOUNTED"~") == -1)
+        if (unlink(_PATH_MOUNTED "~") == -1)
         {
- -                fprintf(stderr, "Can't remove "MOUNTED"~");
+                fprintf(stderr, "Can't remove " _PATH_MOUNTED "~");
                 return 1;
         }
 

Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html

------------------------------



Więcej informacji o liście dyskusyjnej pld-devel-pl