summaryrefslogtreecommitdiff
path: root/sys-libs/pwdb/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /sys-libs/pwdb/files
reinit the tree, so we can have metadata
Diffstat (limited to 'sys-libs/pwdb/files')
-rw-r--r--sys-libs/pwdb/files/pwdb-0.62-build.patch114
-rw-r--r--sys-libs/pwdb/files/pwdb-0.62-selinux.patch443
2 files changed, 557 insertions, 0 deletions
diff --git a/sys-libs/pwdb/files/pwdb-0.62-build.patch b/sys-libs/pwdb/files/pwdb-0.62-build.patch
new file mode 100644
index 000000000000..ecef517b1ca3
--- /dev/null
+++ b/sys-libs/pwdb/files/pwdb-0.62-build.patch
@@ -0,0 +1,114 @@
+ - drop ldconfig junk
+ - fix types used in socket functions (socklen_t, not int)
+
+http://bugs.gentoo.org/126977
+ - respect user LDFLAGS
+
+http://bugs.gentoo.org/126695
+ - add missing headers
+ - add missing comma to supp_entry
+
+http://bugs.gentoo.org/137134
+ - don't show traditional warnings
+
+--- Makefile
++++ Makefile
+@@ -71,7 +71,7 @@
+
+ WARNINGS += -ansi -D_POSIX_SOURCE -Wall -Wwrite-strings \
+ -Wcast-qual -Wcast-align \
+- -Wtraditional -Wstrict-prototypes -Wmissing-prototypes \
++ -Wstrict-prototypes -Wmissing-prototypes \
+ -Wnested-externs -Winline -Wshadow
+ INCLUDEDIR=-I$(CRTDIR)/include
+
+--- libpwdb/Makefile
++++ libpwdb/Makefile
+@@ -50,7 +50,7 @@
+
+
+ $(LIBDYNAME): $(LIBOBJ)
+- $(LD) -soname $(LIBSONAME) -x -shared -o $(LIBFILENAME) $(LIBOBJ) -lcrypt -lnsl -lc
++ $(CC) $(LDFLAGS) -shared -Wl,-soname -Wl,$(LIBSONAME) -Wl,-x -o $(LIBFILENAME) $(LIBOBJ) -lcrypt -lnsl $(LDLIBS)
+ @ln -sf $(LIBFILENAME) $@
+
+ $(LIBSTATIC): $(LIBOBJ)
+@@ -68,7 +68,7 @@
+ $(INSTALL) -m 644 radius.h $(INCLUDED)/radius.h
+ $(INSTALL) -m 644 _pwdb_macros.h $(INCLUDED)/_pwdb_macros.h
+ $(INSTALL) -m 755 $(LIBFILENAME) $(LIBDIR)
+- $(LDCONFIG)
++ ln -sf $(LIBFILENAME) $(LIBDIR)/$(LIBSONAME)
+ ln -sf $(LIBFILENAME) $(LIBDIR)/$(LIBDYNAME)
+ $(INSTALL) -m 644 $(LIBSTATIC) $(LIBDIR)
+
+--- libpwdb/posix/pwd.c
++++ libpwdb/posix/pwd.c
+@@ -7,6 +7,7 @@
+ */
+
+ #include <stdio.h>
++#include <string.h>
+
+ #define PWDB_HARD_CORE 1
+ #include <pwdb/pwdb_public.h>
+--- libpwdb/posix/undefined.c
++++ libpwdb/posix/undefined.c
+@@ -5,6 +5,7 @@
+ */
+
+ #include <stdio.h>
++#include <stdlib.h>
+
+ #define PWDB_HARD_CORE 1
+ #include <pwdb/pwdb_public.h>
+--- libpwdb/pwdb/pwdb_helper.c
++++ libpwdb/pwdb/pwdb_helper.c
+@@ -18,6 +18,7 @@
+ *
+ */
+
++#include <string.h>
+ #include "pwdb_public.h"
+ #include "pwdb_module.h"
+
+--- libpwdb/pwdb/interface/shadow/group.c
++++ libpwdb/pwdb/interface/shadow/group.c
+@@ -533,7 +533,7 @@
+
+ static const char *supp_entry[] = {
+ "group", "passwd",
+- "users", "admins" /* these are from /etc/group */
++ "users", "admins", /* these are from /etc/group */
+ "groups", /* these are serviced by requests */
+ NULL
+ };
+--- libpwdb/radius/radius.c
++++ libpwdb/radius/radius.c
+@@ -145,7 +145,7 @@
+ const char* password,
+ RADIUS_RESULT *rad_result)
+ {
+- int salen;
++ socklen_t salen;
+ int sockfd;
+ struct sockaddr saremote;
+ struct sockaddr_in *s_in;
+@@ -333,7 +333,7 @@
+ const char* new_password,
+ RADIUS_RESULT *rad_result)
+ {
+- int salen;
++ socklen_t salen;
+ int sockfd;
+ struct sockaddr saremote;
+ struct sockaddr_in *s_in;
+@@ -535,7 +535,7 @@
+ int sense,
+ int session_time)
+ {
+- int salen;
++ socklen_t salen;
+ int sockfd;
+ struct sockaddr saremote;
+ struct sockaddr_in *s_in;
diff --git a/sys-libs/pwdb/files/pwdb-0.62-selinux.patch b/sys-libs/pwdb/files/pwdb-0.62-selinux.patch
new file mode 100644
index 000000000000..106be5645176
--- /dev/null
+++ b/sys-libs/pwdb/files/pwdb-0.62-selinux.patch
@@ -0,0 +1,443 @@
+--- pwdb-0.62/examples/Makefile.pwdbselinux 1998-10-06 19:57:04.000000000 -0400
++++ pwdb-0.62/examples/Makefile 2003-07-09 14:45:54.702663000 -0400
+@@ -4,6 +4,8 @@ PROGS = posix gentest tpwdb radtest grou
+ SRCS = $(addsuffix .c,$(PROGS))
+ OBJS = $(addsuffix .o,$(PROGS))
+
++SELINUXLIBS = -lselinux
++
+ # rules
+ junk:
+ @echo "this is not a top-level Makefile"
+@@ -14,20 +16,20 @@ junk:
+
+ all: ${PROGS} ../libpwdb/libpwdb.a
+
+-posix: posix.o ../libpwdb/libpwdb.a
+- $(CC) -o $@ $< ../libpwdb/libpwdb.a -lnsl
++posix: posix.o ../libpwdb/libpwdb.a
++ $(CC) -o $@ $< ../libpwdb/libpwdb.a -lnsl ${SELINUXLIBS}
+
+ tpwdb: tpwdb.o ../libpwdb/libpwdb.a
+- ${CC} -g -o $@ $< ../libpwdb/libpwdb.a -lnsl
++ ${CC} -g -o $@ $< ../libpwdb/libpwdb.a -lnsl ${SELINUXLIBS}
+
+ radtest: radtest.o ../libpwdb/libpwdb.a
+- ${CC} -g -o $@ $< ../libpwdb/libpwdb.a -lnsl
++ ${CC} -g -o $@ $< ../libpwdb/libpwdb.a -lnsl ${SELINUXLIBS}
+
+ gentest: gentest.o ../libpwdb/libpwdb.a
+- ${CC} -g -o $@ $< ../libpwdb/libpwdb.a -lnsl
++ ${CC} -g -o $@ $< ../libpwdb/libpwdb.a -lnsl ${SELINUXLIBS}
+
+ grouptest: grouptest.o ../libpwdb/libpwdb.a
+- ${CC} -g -o $@ $< ../libpwdb/libpwdb.a -lnsl
++ ${CC} -g -o $@ $< ../libpwdb/libpwdb.a -lnsl ${SELINUXLIBS}
+
+ clean:
+ rm -f ${PROGS} *.o *~
+--- pwdb-0.62/libpwdb/shadow/shadowio.c.pwdbselinux 1998-10-06 16:58:43.000000000 -0400
++++ pwdb-0.62/libpwdb/shadow/shadowio.c 2003-07-09 14:45:54.705662544 -0400
+@@ -16,6 +16,12 @@
+
+ #include "../_pwdb_internal.h"
+
++#ifdef WITH_SELINUX
++#include <selinux/selinux.h>
++static int selinux_enabled=0;
++static security_context_t prev_context=NULL;
++#endif
++
+ struct spw_file_entry {
+ char *spwf_line;
+ int spwf_changed;
+@@ -259,8 +265,28 @@ int __pwdb_spw_close (void)
+ if (fstat (fileno (spwfp), &sb))
+ return 0;
+
+- if (create_backup_file(spwfp, backup, &sb))
+- return 0;
++#ifdef WITH_SELINUX
++ if (selinux_enabled=is_selinux_enabled()) {
++ security_context_t passwd_context=NULL;
++ if (fgetfilecon(fileno (spwfp),&passwd_context)<0) {
++ return 0;
++ };
++ if (getfscreatecon(&prev_context)<0) {
++ freecon(passwd_context);
++ return 0;
++ }
++ if (setfscreatecon(passwd_context)) {
++ freecon(passwd_context);
++ freecon(prev_context);
++ return 0;
++ }
++ freecon(passwd_context);
++ }
++#endif
++ if (create_backup_file(spwfp, backup, &sb)){
++ errors++;
++ goto errorexit;
++ }
+
+ isopen = 0;
+ (void) fclose (spwfp);
+@@ -278,11 +304,15 @@ int __pwdb_spw_close (void)
+ */
+
+ spwfp = fopen_with_umask(newfile, "w", 0777);
+- if (!spwfp)
+- return 0;
++ if (!spwfp){
++ errors++;
++ goto errorexit;
++ }
+ if (chown(newfile, sb.st_uid, sb.st_gid) ||
+- chmod(newfile, sb.st_mode))
+- return 0;
++ chmod(newfile, sb.st_mode)){
++ errors++;
++ goto errorexit;
++ }
+
+ /*
+ * Check each member in the list and write out any elements
+@@ -308,7 +338,7 @@ int __pwdb_spw_close (void)
+
+ if (errors) {
+ unlink (newfile);
+- return 0;
++ goto errorexit;
+ }
+
+ /*
+@@ -352,7 +382,20 @@ int __pwdb_spw_close (void)
+ }
+ spwf_tail = 0;
+ isopen = 0;
+- return 1;
++
++ errorexit:
++#ifdef WITH_SELINUX
++ if (selinux_enabled) {
++ if (setfscreatecon(prev_context)) {
++ errors++;
++ }
++ if (prev_context != NULL) {
++ freecon(prev_context);
++ prev_context=NULL;
++ }
++ }
++#endif
++ return errors==0;
+ }
+
+ int __pwdb_spw_update (const struct __pwdb_spwd *spwd)
+--- pwdb-0.62/libpwdb/shadow/sgroupio.c.pwdbselinux 1998-10-06 16:58:43.000000000 -0400
++++ pwdb-0.62/libpwdb/shadow/sgroupio.c 2003-07-09 14:45:54.704662696 -0400
+@@ -16,6 +16,12 @@
+
+ #include "../_pwdb_internal.h"
+
++#ifdef WITH_SELINUX
++#include <selinux/selinux.h>
++static int selinux_enabled=0;
++static security_context_t prev_context=NULL;
++#endif
++
+ static int islocked;
+ static int isopen;
+ static int open_modes;
+@@ -278,8 +284,28 @@ int __pwdb_sgr_close (void)
+ if (fstat (fileno (sgrfp), &sb))
+ return 0;
+
+- if (create_backup_file(sgrfp, backup, &sb))
+- return 0;
++#ifdef WITH_SELINUX
++ if (selinux_enabled=is_selinux_enabled()) {
++ security_context_t passwd_context=NULL;
++ if (fgetfilecon(fileno (sgrfp),&passwd_context)<0) {
++ return 0;
++ };
++ if (getfscreatecon(&prev_context)<0) {
++ freecon(passwd_context);
++ return 0;
++ }
++ if (setfscreatecon(passwd_context)) {
++ freecon(passwd_context);
++ freecon(prev_context);
++ return 0;
++ }
++ freecon(passwd_context);
++ }
++#endif
++ if (create_backup_file(sgrfp, backup, &sb)){
++ errors++;
++ goto errorexit;
++ }
+
+ isopen = 0;
+ (void) fclose (sgrfp);
+@@ -296,11 +322,15 @@ int __pwdb_sgr_close (void)
+ */
+
+ sgrfp = fopen_with_umask(newfile, "w", 0777);
+- if (!sgrfp)
+- return 0;
++ if (!sgrfp){
++ errors++;
++ goto errorexit;
++ }
+ if (chown(newfile, sb.st_uid, sb.st_gid) ||
+- chmod(newfile, sb.st_mode))
+- return 0;
++ chmod(newfile, sb.st_mode)){
++ errors++;
++ goto errorexit;
++ }
+
+ /*
+ * Check each member in the list and write out any elements
+@@ -326,7 +356,7 @@ int __pwdb_sgr_close (void)
+
+ if (errors) {
+ unlink (newfile);
+- return 0;
++ goto errorexit;
+ }
+
+ /*
+@@ -370,7 +400,20 @@ int __pwdb_sgr_close (void)
+ }
+ sgr_tail = 0;
+ isopen = 0;
+- return 1;
++
++ errorexit:
++#ifdef WITH_SELINUX
++ if (selinux_enabled) {
++ if (setfscreatecon(prev_context)) {
++ errors++;
++ }
++ if (prev_context != NULL) {
++ freecon(prev_context);
++ prev_context=NULL;
++ }
++ }
++#endif
++ return errors==0;
+ }
+
+ int __pwdb_sgr_update (const struct __pwdb_sgrp *sgrent)
+--- pwdb-0.62/libpwdb/unix/pwio.c.pwdbselinux 1998-10-06 16:58:43.000000000 -0400
++++ pwdb-0.62/libpwdb/unix/pwio.c 2003-07-09 14:45:54.707662240 -0400
+@@ -16,6 +16,11 @@
+
+ #include "../_pwdb_internal.h"
+
++#ifdef WITH_SELINUX
++#include <selinux/selinux.h>
++static int selinux_enabled=0;
++static security_context_t prev_context=NULL;
++#endif
+ struct pw_file_entry {
+ char *pwf_line;
+ int pwf_changed;
+@@ -204,8 +209,28 @@ int __pwdb_pw_close (void)
+ if (fstat (fileno (pwfp), &sb))
+ return 0;
+
+- if (create_backup_file(pwfp, backup, &sb))
+- return 0;
++#ifdef WITH_SELINUX
++ if (selinux_enabled=is_selinux_enabled()) {
++ security_context_t passwd_context=NULL;
++ if (fgetfilecon(fileno (pwfp),&passwd_context)<0) {
++ return 0;
++ };
++ if (getfscreatecon(&prev_context)<0) {
++ freecon(passwd_context);
++ return 0;
++ }
++ if (setfscreatecon(passwd_context)) {
++ freecon(passwd_context);
++ freecon(prev_context);
++ return 0;
++ }
++ freecon(passwd_context);
++ }
++#endif
++ if (create_backup_file(pwfp, backup, &sb)) {
++ errors++;
++ goto errorexit;
++ }
+
+ isopen = 0;
+ (void) fclose (pwfp);
+@@ -222,11 +247,15 @@ int __pwdb_pw_close (void)
+ */
+
+ pwfp = fopen_with_umask(newfile, "w", 0777);
+- if (!pwfp)
+- return 0;
++ if (!pwfp) {
++ errors++;
++ goto errorexit;
++ }
+ if (chown(newfile, sb.st_uid, sb.st_gid) ||
+- chmod(newfile, sb.st_mode))
+- return 0;
++ chmod(newfile, sb.st_mode)) {
++ errors++;
++ goto errorexit;
++ }
+
+ /*
+ * Check each member in the list and write out any elements
+@@ -251,7 +280,7 @@ int __pwdb_pw_close (void)
+
+ if (errors) {
+ unlink (newfile);
+- return 0;
++ goto errorexit;
+ }
+
+ /*
+@@ -294,7 +323,20 @@ int __pwdb_pw_close (void)
+ }
+ pwf_tail = 0;
+ isopen = 0;
+- return 1;
++
++ errorexit:
++#ifdef WITH_SELINUX
++ if (selinux_enabled) {
++ if (setfscreatecon(prev_context)) {
++ errors++;
++ }
++ if (prev_context != NULL) {
++ freecon(prev_context);
++ prev_context=NULL;
++ }
++ }
++#endif
++ return errors==0;
+ }
+
+ /*
+--- pwdb-0.62/libpwdb/unix/groupio.c.pwdbselinux 1998-10-06 16:58:43.000000000 -0400
++++ pwdb-0.62/libpwdb/unix/groupio.c 2003-07-09 14:45:54.708662088 -0400
+@@ -11,6 +11,12 @@
+ #include "../_pwdb_internal.h"
+
+
++#ifdef WITH_SELINUX
++#include <selinux/selinux.h>
++int selinux_enabled=0;
++static security_context_t prev_context=NULL;
++#endif
++
+ static int islocked;
+ static int isopen;
+ static int open_modes;
+@@ -259,8 +265,28 @@ int __pwdb_gr_close (void)
+ if (fstat (fileno (grfp), &sb))
+ return 0;
+
+- if (create_backup_file(grfp, backup, &sb))
+- return 0;
++#ifdef WITH_SELINUX
++ if (selinux_enabled=is_selinux_enabled()) {
++ security_context_t group_context=NULL;
++ if (fgetfilecon(fileno (grfp),&group_context)<0) {
++ return 0;
++ };
++ if (getfscreatecon(&prev_context)<0) {
++ freecon(group_context);
++ return 0;
++ }
++ if (setfscreatecon(group_context)) {
++ freecon(group_context);
++ freecon(prev_context);
++ return 0;
++ }
++ freecon(group_context);
++ }
++#endif
++ if (create_backup_file(grfp, backup, &sb)) {
++ errors++;
++ goto errorexit;
++ }
+
+ isopen = 0;
+ (void) fclose (grfp);
+@@ -278,11 +304,15 @@ int __pwdb_gr_close (void)
+ */
+
+ grfp = fopen_with_umask(newfile, "w", 0777);
+- if (!grfp)
+- return 0;
++ if (!grfp) {
++ errors++;
++ goto errorexit;
++ }
+ if (chown(newfile, sb.st_uid, sb.st_gid) ||
+- chmod(newfile, sb.st_mode))
+- return 0;
++ chmod(newfile, sb.st_mode)) {
++ errors++;
++ goto errorexit;
++ }
+
+ /*
+ * Check each member in the list and write out any elements
+@@ -308,7 +338,7 @@ int __pwdb_gr_close (void)
+
+ if (errors) {
+ unlink (newfile);
+- return 0;
++ goto errorexit;
+ }
+
+ /*
+@@ -351,7 +381,19 @@ int __pwdb_gr_close (void)
+ }
+ grf_tail = 0;
+ isopen = 0;
+- return 1;
++ errorexit:
++#ifdef WITH_SELINUX
++ if (selinux_enabled) {
++ if (setfscreatecon(prev_context)) {
++ errors++;
++ }
++ if (prev_context != NULL) {
++ freecon(prev_context);
++ prev_context=NULL;
++ }
++ }
++#endif
++ return errors==0;
+ }
+
+ /* update an entry */
+--- pwdb-0.62/libpwdb/Makefile.pwdbselinux 1999-04-10 05:31:20.000000000 -0400
++++ pwdb-0.62/libpwdb/Makefile 2003-07-09 14:45:54.709661936 -0400
+@@ -22,7 +22,7 @@ HEADERS = pwdb/pwdb_public.h pwdb/pwdb_c
+
+ # needed for generic interface compilation
+ # if header files are not installed (CG)
+-CFLAGS+=-I.
++CFLAGS+=-I. -DWITH_SELINUX
+
+ CFLAGS+=# -DDEBUG
+
+@@ -50,6 +50,7 @@
+
+ all: $(LIBSTATIC) $(LIBDYNAME)
+
++$(LIBDYNAME): LDLIBS += -lselinux
+
+ $(LIBDYNAME): $(LIBOBJ)
+ $(CC) $(LDFLAGS) -shared -Wl,-soname -Wl,$(LIBSONAME) -Wl,-x -o $(LIBFILENAME) $(LIBOBJ) -lcrypt -lnsl $(LDLIBS)