mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
samba3 fixed
This commit is contained in:
parent
9a0dcfd895
commit
4c377f65b5
15 changed files with 8048 additions and 0 deletions
4
samba3/Config.in
Normal file
4
samba3/Config.in
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
config SAMBA3_DEBUG
|
||||
bool "Enable Logging for samba3"
|
||||
depends PACKAGE_samba3
|
||||
default n
|
||||
83
samba3/Makefile
Normal file
83
samba3/Makefile
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
#
|
||||
# Copyright (C) 2008-2011 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=samba3
|
||||
PKG_VERSION:=3.0.24
|
||||
PKG_RELEASE:=8
|
||||
PKG_MD5SUM:=89273f67a6d8067cbbecefaa13747153
|
||||
|
||||
PKG_SOURCE_URL:=ftp://ftp.samba.org/pub/samba/old-versions/
|
||||
PKG_SOURCE:=samba-$(PKG_VERSION).tar.gz
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/samba-$(PKG_VERSION)/
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
TARGET_CFLAGS+=$(if $(CONFIG_SAMBA3_DEBUG),-DSAMBA_DEBUG)
|
||||
|
||||
define Package/samba3
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Filesystem
|
||||
TITLE:=samba3
|
||||
DEPENDS:=+libpthread
|
||||
URL:=http://www.samba.org/
|
||||
endef
|
||||
|
||||
define Package/samba3/Description
|
||||
Samba3 - made small with patches taken from AVM GPL releases and freetz
|
||||
endef
|
||||
|
||||
define Package/samba3/conffiles
|
||||
/etc/config/samba
|
||||
/etc/samba/smb.conf.template
|
||||
endef
|
||||
|
||||
define Package/samba3/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
define Build/Prepare/LFS
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
$(call Build/Prepare/Default)
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
[ -f "$(PKG_BUILD_DIR)/source/include/config.h.save" ] || \
|
||||
$(CP) $(PKG_BUILD_DIR)/source/include/config.h \
|
||||
$(PKG_BUILD_DIR)/source/include/config.h.save
|
||||
cat \
|
||||
$(PKG_BUILD_DIR)/source/include/config.h.save \
|
||||
./files/config-lfs.h >> $(PKG_BUILD_DIR)/source/include/config.h
|
||||
$(Build/Configure/Default)
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
CC="$(TARGET_CC)" \
|
||||
CFLAGS="$(TARGET_CFLAGS)" \
|
||||
CPPFLAGS="$(TARGET_CPPFLAGS)" \
|
||||
LDFLAGS="$(TARGET_LDFLAGS)" \
|
||||
$(MAKE) -C $(PKG_BUILD_DIR)/source \
|
||||
$(TARGET_CONFIGURE_OPTS) \
|
||||
all bin/smbpasswd
|
||||
endef
|
||||
|
||||
define Package/samba3/install
|
||||
$(INSTALL_DIR) $(1)/etc/{samba,init.d,config}
|
||||
$(INSTALL_BIN) ./files/samba.init $(1)/etc/init.d/samba
|
||||
$(INSTALL_DATA) ./files/samba.config $(1)/etc/config/samba
|
||||
$(INSTALL_DATA) ./files/smb.conf.template $(1)/etc/samba/
|
||||
touch $(1)/etc/samba/smbpasswd
|
||||
$(INSTALL_DIR) $(1)/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/source/bin/smbpasswd $(1)/bin/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/source/bin/smbd $(1)/bin/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/source/bin/nmbd $(1)/bin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,samba3))
|
||||
56
samba3/files/config-lfs.h
Normal file
56
samba3/files/config-lfs.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#undef HAVE_CREAT64
|
||||
#define HAVE_CREAT64 1
|
||||
|
||||
#undef HAVE_FSEEKO64
|
||||
#define HAVE_FSEEKO64 1
|
||||
|
||||
#undef HAVE_FSTAT64
|
||||
#define HAVE_FSTAT64 1
|
||||
|
||||
#undef HAVE_FTELLO64
|
||||
#define HAVE_FTELLO64 1
|
||||
|
||||
#undef HAVE_FTRUNCATE64
|
||||
#define HAVE_FTRUNCATE64 1
|
||||
|
||||
#undef HAVE_LSEEK64
|
||||
#define HAVE_LSEEK64 1
|
||||
|
||||
#undef HAVE_LSTAT64
|
||||
#define HAVE_LSTAT64 1
|
||||
|
||||
#undef HAVE_OPEN64
|
||||
#define HAVE_OPEN64 1
|
||||
|
||||
#undef HAVE_PREAD64
|
||||
#define HAVE_PREAD64 1
|
||||
|
||||
#undef HAVE_PWRITE64
|
||||
#define HAVE_PWRITE64 1
|
||||
|
||||
#undef HAVE_READDIR64
|
||||
#define HAVE_READDIR64 1
|
||||
|
||||
#undef HAVE_STAT64
|
||||
#define HAVE_STAT64 1
|
||||
|
||||
#undef HAVE_STRUCT_FLOCK64
|
||||
#define HAVE_STRUCT_FLOCK64 1
|
||||
|
||||
#undef SIZEOF_LONG_LONG
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
|
||||
#undef SIZEOF_OFF_T
|
||||
#define SIZEOF_OFF_T 8
|
||||
|
||||
#undef _FILE_OFFSET_BITS
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
#undef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
|
||||
#undef _LARGEFILE_SOURCE
|
||||
#define _LARGEFILE_SOURCE 1
|
||||
|
||||
#undef _LARGEFILE64_SOURCE
|
||||
#define _LARGEFILE64_SOURCE 1
|
||||
7
samba3/files/samba.config
Normal file
7
samba3/files/samba.config
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
config samba
|
||||
option 'name' 'IntenoSMB'
|
||||
option 'workgroup' 'IntenoSMB'
|
||||
option 'description' 'IntenoSMB'
|
||||
option 'homes' '0'
|
||||
option 'interface' 'lan'
|
||||
|
||||
139
samba3/files/samba.init
Executable file
139
samba3/files/samba.init
Executable file
|
|
@ -0,0 +1,139 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2008-2012 OpenWrt.org
|
||||
|
||||
START=60
|
||||
USE_PROCD=1
|
||||
|
||||
useradd()
|
||||
{
|
||||
local user
|
||||
local password
|
||||
config_get user $1 user
|
||||
config_get password $1 password
|
||||
grep -rq "^$user:" /etc/passwd || adduser $user -s /bin/false -D -H -h /mnt/$user
|
||||
/bin/smbpasswd $user $password
|
||||
}
|
||||
|
||||
purgepasswd()
|
||||
{
|
||||
for us in `grep mnt /etc/passwd | cut -d":" -f1`; do
|
||||
deluser $us
|
||||
done
|
||||
}
|
||||
|
||||
purgesmbpasswd()
|
||||
{
|
||||
rm -rf /etc/samba/smbpasswd
|
||||
touch /etc/samba/smbpasswd
|
||||
}
|
||||
|
||||
smb_header() {
|
||||
local interface
|
||||
config_get interface $1 interface "loopback lan"
|
||||
|
||||
# resolve interfaces
|
||||
local interfaces=$(
|
||||
. /lib/functions/network.sh
|
||||
|
||||
local net
|
||||
for net in $interface; do
|
||||
local device
|
||||
network_get_device device "$net" && {
|
||||
local subnet
|
||||
network_get_subnet subnet "$net" && echo -n "$subnet "
|
||||
network_get_subnet6 subnet "$net" && echo -n "$subnet "
|
||||
}
|
||||
|
||||
echo -n "${device:-$net} "
|
||||
done
|
||||
)
|
||||
|
||||
local name workgroup description charset
|
||||
local hostname="$(uci_get system.@system[0].hostname)"
|
||||
|
||||
config_get name $1 name "${hostname:-OpenWrt}"
|
||||
config_get workgroup $1 workgroup "${hostname:-OpenWrt}"
|
||||
config_get description $1 description "Samba on ${hostname:-OpenWrt}"
|
||||
config_get charset $1 charset "UTF-8"
|
||||
|
||||
mkdir -p /var/etc
|
||||
sed -e "s#|NAME|#$name#g" \
|
||||
-e "s#|WORKGROUP|#$workgroup#g" \
|
||||
-e "s#|DESCRIPTION|#$description#g" \
|
||||
-e "s#|INTERFACES|#$interfaces#g" \
|
||||
-e "s#|CHARSET|#$charset#g" \
|
||||
/etc/samba/smb.conf.template > /var/etc/smb.conf
|
||||
|
||||
local homes
|
||||
config_get_bool homes $1 homes 0
|
||||
[ $homes -gt 0 ] && {
|
||||
cat <<EOT >> /var/etc/smb.conf
|
||||
|
||||
[homes]
|
||||
comment = Home Directories
|
||||
browsable = no
|
||||
read only = no
|
||||
create mode = 0750
|
||||
EOT
|
||||
}
|
||||
|
||||
[ -L /etc/samba/smb.conf ] || ln -nsf /var/etc/smb.conf /etc/samba/smb.conf
|
||||
}
|
||||
|
||||
smb_add_share() {
|
||||
local name
|
||||
local path
|
||||
local users
|
||||
local read_only
|
||||
local guest_ok
|
||||
local create_mask
|
||||
local dir_mask
|
||||
local browseable
|
||||
local dirpath
|
||||
|
||||
config_get name $1 name
|
||||
config_get path $1 path
|
||||
config_get users $1 users
|
||||
config_get read_only $1 read_only
|
||||
config_get guest_ok $1 guest_ok
|
||||
config_get create_mask $1 create_mask
|
||||
config_get dir_mask $1 dir_mask
|
||||
config_get browseable $1 browseable
|
||||
config_get dirpath $1 dirpath
|
||||
path="$path/$dirpath"
|
||||
|
||||
[ -z "$name" -o -z "$path" ] && return
|
||||
|
||||
echo -e "\n[$name]\n\tpath = $path" >> /var/etc/smb.conf
|
||||
[ -n "$users" ] && echo -e "\tvalid users = $users" >> /var/etc/smb.conf
|
||||
[ -n "$read_only" ] && echo -e "\tread only = $read_only" >> /var/etc/smb.conf
|
||||
[ -n "$guest_ok" ] && echo -e "\tguest ok = $guest_ok" >> /var/etc/smb.conf
|
||||
[ -n "$create_mask" ] && echo -e "\tcreate mask = $create_mask" >> /var/etc/smb.conf
|
||||
[ -n "$dir_mask" ] && echo -e "\tdirectory mask = $dir_mask" >> /var/etc/smb.conf
|
||||
[ -n "$browseable" ] && echo -e "\tbrowseable = $browseable" >> /var/etc/smb.conf
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load samba
|
||||
config_foreach useradd sambausers
|
||||
config_foreach smb_header samba
|
||||
config_foreach smb_add_share sambashare
|
||||
service_start /bin/smbd -D
|
||||
service_start /bin/nmbd -D
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
service_stop /bin/smbd
|
||||
service_stop /bin/nmbd
|
||||
purgepasswd
|
||||
purgesmbpasswd
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger samba network
|
||||
}
|
||||
19
samba3/files/smb.conf.template
Normal file
19
samba3/files/smb.conf.template
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[global]
|
||||
netbios name = |NAME|
|
||||
workgroup = |WORKGROUP|
|
||||
server string = |DESCRIPTION|
|
||||
syslog = 10
|
||||
encrypt passwords = true
|
||||
passdb backend = smbpasswd
|
||||
obey pam restrictions = yes
|
||||
socket options = TCP_NODELAY
|
||||
unix charset = UTF-8
|
||||
preferred master = yes
|
||||
os level = 20
|
||||
security = user
|
||||
guest account = nobody
|
||||
invalid users = root
|
||||
smb passwd file = /etc/samba/smbpasswd
|
||||
interfaces = br-lan
|
||||
bind interfaces only = yes
|
||||
|
||||
7267
samba3/patches/100-avm.patch
Normal file
7267
samba3/patches/100-avm.patch
Normal file
File diff suppressed because it is too large
Load diff
105
samba3/patches/110-compile_fixes.patch
Normal file
105
samba3/patches/110-compile_fixes.patch
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
Index: samba-3.0.24/source/Makefile
|
||||
===================================================================
|
||||
--- samba-3.0.24.orig/source/Makefile 2008-08-07 11:15:02.000000000 +0200
|
||||
+++ samba-3.0.24/source/Makefile 2008-08-07 11:18:28.000000000 +0200
|
||||
@@ -10,8 +10,6 @@
|
||||
SOURCEROOT=$(shell pwd)/../../../..
|
||||
SHAREDLIBS=$(SOURCEROOT)/sharedlibs
|
||||
|
||||
-include ${SHAREDLIBS}/ar7def.mk
|
||||
-
|
||||
# AR7
|
||||
# prefix=/usr/local/samba
|
||||
prefix=/var/samba
|
||||
@@ -22,25 +20,27 @@
|
||||
LIBS= -lcrypt -ldl -lpthread
|
||||
# AR7
|
||||
# CC=gcc
|
||||
-CC=${TARGET}-gcc
|
||||
+CC?=${TARGET}-gcc
|
||||
RANLIB = ${TARGET}-ranlib
|
||||
AR = ${TARGET}-ar
|
||||
|
||||
SHLD=${CC} ${CFLAGS}
|
||||
# AR7
|
||||
# CFLAGS= -O -D_SAMBA_BUILD_
|
||||
-CFLAGS= -Os -D_SAMBA_BUILD_ -DAVM_NO_PRINTING
|
||||
-CFLAGS+= -DAVM_NO_POPT
|
||||
+CFLAPGS?=
|
||||
+CFLAGS+= -Os -D_SAMBA_BUILD_ -DAVM_NO_PRINTING
|
||||
+#CFLAGS+= -DAVM_NO_POPT
|
||||
CFLAGS+= -DAVM_SMALLER
|
||||
-
|
||||
+#CFLAGS+= -DSAMBA_DEBUG
|
||||
# uncomment this to get debugs
|
||||
# CFLAGS += -DSAMBA_DEBUG
|
||||
|
||||
# AR7
|
||||
# CPPFLAGS= -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
|
||||
-CPPFLAGS= -D_GNU_SOURCE
|
||||
+CPPFLAGS?= -D_GNU_SOURCE
|
||||
+CPPFLAGS+= -D_GNU_SOURCE
|
||||
EXEEXT=
|
||||
-LDFLAGS=
|
||||
+LDFLAGS?=
|
||||
AR=ar
|
||||
LDSHFLAGS=-shared -Wl,-Bsymbolic
|
||||
WINBIND_NSS_LDSHFLAGS=-shared -Wl,-Bsymbolic
|
||||
|
||||
Index: samba-3.0.24/source/popt/popt.c
|
||||
===================================================================
|
||||
--- samba-3.0.24.orig/source/popt/popt.c 2008-08-07 11:15:00.000000000 +0200
|
||||
+++ samba-3.0.24/source/popt/popt.c 2008-08-07 11:15:02.000000000 +0200
|
||||
@@ -10,13 +10,14 @@
|
||||
|
||||
#include "system.h"
|
||||
|
||||
-#if HAVE_FLOAT_H
|
||||
+//#if HAVE_FLOAT_H
|
||||
#include <float.h>
|
||||
-#endif
|
||||
+//#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "findme.h"
|
||||
#include "poptint.h"
|
||||
+#include "../include/config.h"
|
||||
|
||||
#ifdef MYDEBUG
|
||||
/*@unchecked@*/
|
||||
@@ -384,7 +385,7 @@
|
||||
sprintf(s, "%s/%s", con->execPath, item->argv[0]);
|
||||
argv[argc] = s;
|
||||
} else {
|
||||
- argv[argc] = findProgramPath(item->argv[0]);
|
||||
+ argv[argc] = ""/*findProgramPath(item->argv[0])*/;
|
||||
}
|
||||
if (argv[argc++] == NULL) return POPT_ERROR_NOARG;
|
||||
|
||||
@@ -1235,4 +1236,3 @@
|
||||
|
||||
return numargs;
|
||||
}
|
||||
-/*@=boundswrite@*/
|
||||
Index: samba-3.0.24/source/smbd/server.c
|
||||
===================================================================
|
||||
--- samba-3.0.24.orig/source/smbd/server.c 2008-08-07 11:15:02.000000000 +0200
|
||||
+++ samba-3.0.24/source/smbd/server.c 2008-08-07 11:15:02.000000000 +0200
|
||||
@@ -47,7 +47,7 @@
|
||||
void _fLog(char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
- FILE *fp = fopen("/var/tmp/smbd.log", "a");
|
||||
+ FILE *fp = fopen("/var/log/smbd.log", "a");
|
||||
time_t t = time(0); /* LOG */
|
||||
|
||||
if (!fp) return;
|
||||
@@ -63,7 +63,7 @@
|
||||
void _fDebug(char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
- FILE *fp = fopen("/var/tmp/smbd.log", "a");
|
||||
+ FILE *fp = fopen("/var/log/smbd.log", "a");
|
||||
time_t t = time(0); /* LOG */
|
||||
|
||||
if (!fp) return;
|
||||
57
samba3/patches/120-owrt_paths.patch
Normal file
57
samba3/patches/120-owrt_paths.patch
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
Index: samba-3.0.24/source/Makefile
|
||||
===================================================================
|
||||
--- samba-3.0.24.orig/source/Makefile 2008-08-06 23:33:20.000000000 +0200
|
||||
+++ samba-3.0.24/source/Makefile 2008-08-06 23:34:48.000000000 +0200
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
# AR7
|
||||
# prefix=/usr/local/samba
|
||||
-prefix=/var/samba
|
||||
+prefix=
|
||||
exec_prefix=${prefix}
|
||||
|
||||
# AR7
|
||||
@@ -108,11 +108,11 @@
|
||||
# These can be overridden by command line switches (see smbd(8))
|
||||
# or in smb.conf (see smb.conf(5))
|
||||
LOGFILEBASE = ${VARDIR}
|
||||
-CONFIGFILE = $(CONFIGDIR)/smb.conf
|
||||
-LMHOSTSFILE = $(CONFIGDIR)/lmhosts
|
||||
+CONFIGFILE = /etc/samba/smb.conf
|
||||
+LMHOSTSFILE = /etc/lmhosts
|
||||
|
||||
# This is where smbpasswd et al go
|
||||
-PRIVATEDIR = ${prefix}/private
|
||||
+PRIVATEDIR = /etc/samba/
|
||||
|
||||
SMB_PASSWD_FILE = $(PRIVATEDIR)/smbpasswd
|
||||
PRIVATE_DIR = $(PRIVATEDIR)
|
||||
@@ -121,10 +121,10 @@
|
||||
SWATDIR = ${prefix}/swat
|
||||
|
||||
# the directory where lock files go
|
||||
-LOCKDIR = ${VARDIR}/locks
|
||||
+LOCKDIR = ${VARDIR}/lock
|
||||
|
||||
# the directory where pid files go
|
||||
-PIDDIR = ${VARDIR}/locks
|
||||
+PIDDIR = ${VARDIR}/lock
|
||||
|
||||
LIBSMBCLIENT=bin/libsmbclient.a bin/libsmbclient.so
|
||||
LIBSMBCLIENT_MAJOR=0
|
||||
Index: samba-3.0.24/source/lib/util.c
|
||||
===================================================================
|
||||
--- samba-3.0.24.orig/source/lib/util.c 2008-08-06 23:41:58.000000000 +0200
|
||||
+++ samba-3.0.24/source/lib/util.c 2008-08-06 23:42:10.000000000 +0200
|
||||
@@ -300,11 +300,7 @@
|
||||
char *p;
|
||||
if ((p = getenv("TMPDIR")))
|
||||
return p;
|
||||
-#if 1 /* AR7 */
|
||||
- return "/var/tmp";
|
||||
-#else
|
||||
return "/tmp";
|
||||
-#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
216
samba3/patches/130-owrt_smbpasswd.patch
Normal file
216
samba3/patches/130-owrt_smbpasswd.patch
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
Index: samba-3.0.24/source/Makefile
|
||||
===================================================================
|
||||
--- samba-3.0.24.orig/source/Makefile 2008-08-07 15:56:45.000000000 +0200
|
||||
+++ samba-3.0.24/source/Makefile 2008-08-07 15:56:45.000000000 +0200
|
||||
@@ -1015,9 +1015,9 @@
|
||||
|
||||
MY_PASS_OBJ = libsmb/smbdes.o lib/md4.o lib/arc4.o
|
||||
|
||||
-bin/smbpasswd: utils/avm_smbpasswd.o $(MY_PASS_OBJ)
|
||||
+bin/smbpasswd: utils/owrt_smbpasswd.o $(MY_PASS_OBJ)
|
||||
@echo Linking $@
|
||||
- @$(CC) $(FLAGS) -o $@ utils/avm_smbpasswd.o $(MY_PASS_OBJ) \
|
||||
+ @$(CC) $(FLAGS) -o $@ utils/owrt_smbpasswd.o $(MY_PASS_OBJ) \
|
||||
-L$(TARGETFS)/lib
|
||||
|
||||
|
||||
Index: samba-3.0.24/source/utils/owrt_smbpasswd.c
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ samba-3.0.24/source/utils/owrt_smbpasswd.c 2008-08-07 15:58:25.000000000 +0200
|
||||
@@ -0,0 +1,195 @@
|
||||
+/*
|
||||
+ * Copyright (C) John Crispin <blogic@openwrt.org>
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify it
|
||||
+ * under the terms of the GNU General Public License as published by the
|
||||
+ * Free Software Foundation; either version 2 of the License, or (at your
|
||||
+ * option) any later version.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
+ * more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public License along with
|
||||
+ * this program; if not, write to the Free Software Foundation, Inc., 675
|
||||
+ * Mass Ave, Cambridge, MA 02139, USA. */
|
||||
+
|
||||
+#include "includes.h"
|
||||
+#include <endian.h>
|
||||
+
|
||||
+void E_md4hash(const char *passwd, uchar p16[16])
|
||||
+{
|
||||
+ int len;
|
||||
+ smb_ucs2_t wpwd[129];
|
||||
+ int i;
|
||||
+
|
||||
+ len = strlen(passwd);
|
||||
+ for (i = 0; i < len; i++) {
|
||||
+#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
+ wpwd[i] = (unsigned char)passwd[i];
|
||||
+#else
|
||||
+ wpwd[i] = (unsigned char)passwd[i] << 8;
|
||||
+#endif
|
||||
+ }
|
||||
+ wpwd[i] = 0;
|
||||
+
|
||||
+ len = len * sizeof(int16);
|
||||
+ mdfour(p16, (unsigned char *)wpwd, len);
|
||||
+ ZERO_STRUCT(wpwd);
|
||||
+}
|
||||
+
|
||||
+/* returns -1 if user is not present in /etc/passwd*/
|
||||
+int find_uid_for_user(char *user)
|
||||
+{
|
||||
+ char t[256];
|
||||
+ FILE *fp = fopen("/etc/passwd", "r");
|
||||
+ int ret = -1;
|
||||
+
|
||||
+ if(!fp)
|
||||
+ {
|
||||
+ printf("failed to open /etc/passwd");
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ while(!feof(fp))
|
||||
+ {
|
||||
+ if(fgets(t, 255, fp))
|
||||
+ {
|
||||
+ char *p1, *p2;
|
||||
+ p1 = strchr(t, ':');
|
||||
+ if(p1 && (p1 - t == strlen(user)) && (strncmp(t, user, strlen(user))) == 0)
|
||||
+ {
|
||||
+ p1 = strchr(t, ':');
|
||||
+ if(!p1)
|
||||
+ goto out;
|
||||
+ p2 = strchr(++p1, ':');
|
||||
+ if(!p2)
|
||||
+ goto out;
|
||||
+ p1 = strchr(++p2, ':');
|
||||
+ if(!p1)
|
||||
+ goto out;
|
||||
+ *p1 = '\0';
|
||||
+ ret = atoi(p2);
|
||||
+ goto out;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ printf("No valid user found in /etc/passwd\n");
|
||||
+
|
||||
+out:
|
||||
+ if(fp)
|
||||
+ fclose(fp);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+void insert_user_in_smbpasswd(char *user, char *line)
|
||||
+{
|
||||
+ char t[256];
|
||||
+ FILE *fp = fopen("/etc/samba/smbpasswd", "r+");
|
||||
+
|
||||
+ if(!fp)
|
||||
+ {
|
||||
+ printf("failed to open /etc/samba/smbpasswd");
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ while(!feof(fp))
|
||||
+ {
|
||||
+ if(fgets(t, 255, fp))
|
||||
+ {
|
||||
+ char *p;
|
||||
+ p = strchr(t, ':');
|
||||
+ if(p && (p - t == strlen(user)) && (strncmp(t, user, strlen(user))) == 0)
|
||||
+ {
|
||||
+ fseek(fp, -strlen(line), SEEK_CUR);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ fprintf(fp, line);
|
||||
+
|
||||
+out:
|
||||
+ if(fp)
|
||||
+ fclose(fp);
|
||||
+}
|
||||
+
|
||||
+void delete_user_from_smbpasswd(char *user)
|
||||
+{
|
||||
+ char t[256];
|
||||
+ FILE *fp = fopen("/etc/samba/smbpasswd", "r+");
|
||||
+
|
||||
+ if(!fp)
|
||||
+ {
|
||||
+ printf("failed to open /etc/samba/smbpasswd");
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ while(!feof(fp))
|
||||
+ {
|
||||
+ if(fgets(t, 255, fp))
|
||||
+ {
|
||||
+ char *p;
|
||||
+ p = strchr(t, ':');
|
||||
+ if(p && (p - t == strlen(user)) && (strncmp(t, user, strlen(user))) == 0)
|
||||
+ {
|
||||
+ fpos_t r_pos, w_pos;
|
||||
+ char t2[256];
|
||||
+ fgetpos(fp, &r_pos);
|
||||
+ w_pos = r_pos;
|
||||
+ w_pos.__pos -= strlen(t);
|
||||
+ while(fgets(t2, 256, fp))
|
||||
+ {
|
||||
+ fsetpos(fp, &w_pos);
|
||||
+ fputs(t2, fp);
|
||||
+ r_pos.__pos += strlen(t2);
|
||||
+ w_pos.__pos += strlen(t2);
|
||||
+ fsetpos(fp, &r_pos);
|
||||
+ }
|
||||
+ ftruncate(fileno(fp), w_pos.__pos);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+out:
|
||||
+ if(fp)
|
||||
+ fclose(fp);
|
||||
+}
|
||||
+
|
||||
+int main(int argc, char **argv)
|
||||
+{
|
||||
+ unsigned uid;
|
||||
+ uchar new_nt_p16[NT_HASH_LEN];
|
||||
+ int g;
|
||||
+ int smbpasswd_present;
|
||||
+ char smbpasswd_line[256];
|
||||
+ char *s;
|
||||
+
|
||||
+ if(argc != 3)
|
||||
+ {
|
||||
+ printf("usage for openwrt_smbpasswd - \n\t%s USERNAME PASSWD\n\t%s -del USERNAME\n", argv[0], argv[0]);
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ if(strcmp(argv[1], "-del") == 0)
|
||||
+ {
|
||||
+ printf("deleting user %s\n", argv[2]);
|
||||
+ delete_user_from_smbpasswd(argv[2]);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ uid = find_uid_for_user(argv[1]);
|
||||
+ if(uid == -1)
|
||||
+ exit(2);
|
||||
+
|
||||
+ E_md4hash(argv[2], new_nt_p16);
|
||||
+ s = smbpasswd_line;
|
||||
+ s += snprintf(s, 256 - (s - smbpasswd_line), "%s:%u:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:", argv[1], uid);
|
||||
+ for(g = 0; g < 16; g++)
|
||||
+ s += snprintf(s, 256 - (s - smbpasswd_line), "%02X", new_nt_p16[g]);
|
||||
+ snprintf(s, 256 - (s - smbpasswd_line), ":[U ]:LCT-00000001:\n");
|
||||
+
|
||||
+ insert_user_in_smbpasswd(argv[1], smbpasswd_line);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
27
samba3/patches/140-no_mmap.patch
Normal file
27
samba3/patches/140-no_mmap.patch
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
Index: samba-3.0.24/source/include/config.h
|
||||
===================================================================
|
||||
--- samba-3.0.24.orig/source/include/config.h 2008-08-08 17:43:08.000000000 +0200
|
||||
+++ samba-3.0.24/source/include/config.h 2008-08-08 17:44:02.000000000 +0200
|
||||
@@ -821,7 +821,7 @@
|
||||
#define HAVE_MKTIME 1
|
||||
|
||||
/* Whether mmap works */
|
||||
-#define HAVE_MMAP 1
|
||||
+/* #define HAVE_MMAP 1 */
|
||||
|
||||
/* Define to 1 if you have the <mntent.h> header file. */
|
||||
#define HAVE_MNTENT_H 1
|
||||
Index: samba-3.0.24/source/tdb/Makefile
|
||||
===================================================================
|
||||
--- samba-3.0.24.orig/source/tdb/Makefile 2008-08-08 17:42:47.000000000 +0200
|
||||
+++ samba-3.0.24/source/tdb/Makefile 2008-08-08 17:44:15.000000000 +0200
|
||||
@@ -2,7 +2,8 @@
|
||||
# Makefile for tdb directory
|
||||
#
|
||||
|
||||
-CFLAGS = -DSTANDALONE -DTDB_DEBUG -g -DHAVE_MMAP=1
|
||||
+CFLAGS = -DSTANDALONE -DTDB_DEBUG -g
|
||||
+#-DHAVE_MMAP=1
|
||||
CC = gcc
|
||||
|
||||
ADMINPROGS = tdbdump tdbbackup
|
||||
15
samba3/patches/150-fix_ls.patch
Normal file
15
samba3/patches/150-fix_ls.patch
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
Index: samba-3.0.24/source/lib/ms_fnmatch.c
|
||||
===================================================================
|
||||
--- samba-3.0.24.orig/source/lib/ms_fnmatch.c 2008-08-11 11:08:03.000000000 +0200
|
||||
+++ samba-3.0.24/source/lib/ms_fnmatch.c 2008-08-11 11:11:33.000000000 +0200
|
||||
@@ -153,6 +153,10 @@
|
||||
int ret, count, i;
|
||||
struct max_n *max_n = NULL;
|
||||
|
||||
+ if (strcmp(pattern, "*") == 0) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
if (strcmp(string, "..") == 0) {
|
||||
string = ".";
|
||||
}
|
||||
13
samba3/patches/160-fix_log.patch
Normal file
13
samba3/patches/160-fix_log.patch
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
Index: samba-3.0.24/source/lib/popt_common.c
|
||||
===================================================================
|
||||
--- samba-3.0.24.orig/source/lib/popt_common.c 2008-08-11 11:25:26.000000000 +0200
|
||||
+++ samba-3.0.24/source/lib/popt_common.c 2008-08-11 11:26:03.000000000 +0200
|
||||
@@ -54,7 +54,7 @@
|
||||
else
|
||||
pname++;
|
||||
|
||||
- pstr_sprintf(logfile, "%s/log.%s", arg, pname);
|
||||
+ pstr_sprintf(logfile, "%s/log/%s.log", arg, pname);
|
||||
lp_set_logfile(logfile);
|
||||
}
|
||||
|
||||
28
samba3/patches/170-no_rpc.patch
Normal file
28
samba3/patches/170-no_rpc.patch
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
--- a/source/include/config.h
|
||||
+++ b/source/include/config.h
|
||||
@@ -986,13 +986,13 @@
|
||||
/* #undef HAVE_ROOT */
|
||||
|
||||
/* Define to 1 if you have the <rpcsvc/nis.h> header file. */
|
||||
-#define HAVE_RPCSVC_NIS_H 1
|
||||
+/* #define HAVE_RPCSVC_NIS_H 1 */
|
||||
|
||||
/* Define to 1 if you have the <rpcsvc/ypclnt.h> header file. */
|
||||
-#define HAVE_RPCSVC_YPCLNT_H 1
|
||||
+/* #define HAVE_RPCSVC_YPCLNT_H 1 */
|
||||
|
||||
/* Define to 1 if you have the <rpcsvc/yp_prot.h> header file. */
|
||||
-#define HAVE_RPCSVC_YP_PROT_H 1
|
||||
+/* #define HAVE_RPCSVC_YP_PROT_H 1 */
|
||||
|
||||
/* Whether there is a conflicting AUTH_ERROR define in rpc/rpc.h */
|
||||
/* #undef HAVE_RPC_AUTH_ERROR_CONFLICT */
|
||||
@@ -1001,7 +1001,7 @@
|
||||
/* #undef HAVE_RPC_NETTYPE_H */
|
||||
|
||||
/* Define to 1 if you have the <rpc/rpc.h> header file. */
|
||||
-#define HAVE_RPC_RPC_H 1
|
||||
+/* #define HAVE_RPC_RPC_H 1 */
|
||||
|
||||
/* Whether mkstemp is secure */
|
||||
#define HAVE_SECURE_MKSTEMP 1
|
||||
12
samba3/patches/180-fix_duplicate_define.patch
Normal file
12
samba3/patches/180-fix_duplicate_define.patch
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
--- a/source/include/config.h
|
||||
+++ b/source/include/config.h
|
||||
@@ -1848,8 +1848,7 @@
|
||||
#define SIZEOF_LONG 4
|
||||
|
||||
/* The size of the 'off_t' type */
|
||||
-/* AR7 #define SIZEOF_OFF_T 8 */
|
||||
-#define SIZEOF_OFF_T 4 /* AR7 */
|
||||
+/* #define SIZEOF_OFF_T 8 */
|
||||
|
||||
/* The size of a `short', as computed by sizeof. */
|
||||
#define SIZEOF_SHORT 2
|
||||
Loading…
Add table
Reference in a new issue