samba36: update to 3.6.11 and refresh patches (based on patch from #12914)
[openwrt.org/openwrt.git] / package / network / services / samba36 / patches / 111-owrt_smbpasswd.patch
blob:a/package/network/services/samba36/patches/111-owrt_smbpasswd.patch -> blob:b/package/network/services/samba36/patches/111-owrt_smbpasswd.patch
--- a/package/network/services/samba36/patches/111-owrt_smbpasswd.patch
+++ b/package/network/services/samba36/patches/111-owrt_smbpasswd.patch
@@ -1,6 +1,6 @@
 --- a/source3/Makefile.in
 +++ b/source3/Makefile.in
-@@ -1017,7 +1017,7 @@ TEST_LP_LOAD_OBJ = param/test_lp_load.o 
+@@ -1025,7 +1025,7 @@ TEST_LP_LOAD_OBJ = param/test_lp_load.o
  
  PASSWD_UTIL_OBJ = utils/passwd_util.o
  
@@ -9,7 +9,7 @@
  		$(PARAM_OBJ) $(LIBSMB_OBJ) $(PASSDB_OBJ) \
  		$(GROUPDB_OBJ) $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \
  		$(POPT_LIB_OBJ) $(SMBLDAP_OBJ) \
-@@ -1789,7 +1789,7 @@ nmbd/nmbd_multicall.o: nmbd/nmbd.c nmbd/
+@@ -1813,7 +1813,7 @@ nmbd/nmbd_multicall.o: nmbd/nmbd.c nmbd/
  		echo "$(COMPILE_CC_PATH)" 1>&2;\
  		$(COMPILE_CC_PATH) >/dev/null 2>&1
  
@@ -18,7 +18,7 @@
  	@echo Compiling $<.c
  	@$(COMPILE_CC_PATH) -Dmain=smbpasswd_main && exit 0;\
  		echo "The following command failed:" 1>&2;\
-@@ -1798,7 +1798,7 @@ utils/smbpasswd_multicall.o: utils/smbpa
+@@ -1822,7 +1822,7 @@ utils/smbpasswd_multicall.o: utils/smbpa
  
  SMBD_MULTI_O = $(patsubst smbd/server.o,smbd/server_multicall.o,$(SMBD_OBJ))
  NMBD_MULTI_O = $(patsubst nmbd/nmbd.o,nmbd/nmbd_multicall.o,$(filter-out $(LIB_DUMMY_OBJ),$(NMBD_OBJ)))
@@ -29,9 +29,9 @@
  MULTICALL_O = $(sort $(SMBD_MULTI_O) $(NMBD_MULTI_O) $(SMBPASSWD_MULTI_O) $(MULTI_O))
 --- /dev/null
 +++ b/source3/utils/owrt_smbpasswd.c
-@@ -0,0 +1,245 @@
+@@ -0,0 +1,249 @@
 +/*
-+ * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
++ * Copyright (C) 2012 Felix Fietkau <nbd@nbd.name>
 + * Copyright (C) 2008 John Crispin <blogic@openwrt.org>
 + *
 + * This program is free software; you can redistribute it and/or modify it
@@ -113,7 +113,7 @@
 +	}
 +
 +	if (!find_passwd_line(fp, user, &p1)) {
-+		printf("User %s not found or invalid in /etc/passwd\n");
++		printf("User %s not found or invalid in /etc/passwd\n", user);
 +		goto out;
 +	}
 +
@@ -157,20 +157,24 @@
 +	int len = strlen(buf);
 +
 +	fgetpos(fp, &r_pos);
-+	w_pos = r_pos;
-+	w_pos.__pos -= len;
++	fseek(fp, -len, SEEK_CUR);
++	fgetpos(fp, &w_pos);
++	fsetpos(fp, &r_pos);
 +
 +	while (fgets(buf, sizeof(buf) - 1, fp)) {
 +		int cur_len = strlen(buf);
 +
 +		fsetpos(fp, &w_pos);
 +		fputs(buf, fp);
-+		r_pos.__pos += cur_len;
-+		w_pos.__pos += cur_len;
++		fgetpos(fp, &w_pos);
++
 +		fsetpos(fp, &r_pos);
-+	}
-+
-+	ftruncate(fileno(fp), w_pos.__pos);
++		fseek(fp, cur_len, SEEK_CUR);
++		fgetpos(fp, &r_pos);
++	}
++
++	fsetpos(fp, &w_pos);
++	ftruncate(fileno(fp), ftello(fp));
 +}
 +
 +static int usage(const char *progname)

comments