adds example of useradd dumping error messages
authorThomas Walker Lynch <thomas.lynch@reasoningtechnology.com>
Tue, 12 Feb 2019 18:50:36 +0000 (19:50 +0100)
committerThomas Walker Lynch <thomas.lynch@reasoningtechnology.com>
Tue, 12 Feb 2019 18:50:36 +0000 (19:50 +0100)
22 files changed:
autom4te.cache/requests
config.log
src/.deps/dbprintf.aux.Po [new file with mode: 0644]
src/.deps/dispatch.lib.Po
src/.deps/dispatch_useradd.lib.Po
src/.deps/subu-mk-0.lib.Po
src/dbprintf.aux.c [new file with mode: 0644]
src/dbprintf.aux.h [new file with mode: 0644]
src/dbprintf.aux.o [new file with mode: 0644]
src/dispatch.lib.c
src/dispatch.lib.o [new file with mode: 0644]
src/dispatch_useradd.lib.o [new file with mode: 0644]
src/local_common.h
src/makefile
src/makefile.am
src/makefile.in
src/setuid_root.sh
src/subu-mk-0 [new file with mode: 0755]
src/subu-mk-0.cli.o [new file with mode: 0644]
src/subu-mk-0.lib.c
src/subu-mk-0.lib.o [new file with mode: 0644]
try/example.txt [new file with mode: 0644]

index 024431f..56690ad 100644 (file)
                         'configure.ac'
                       ],
                       {
-                        'm4_include' => 1,
+                        'AM_MISSING_PROG' => 1,
+                        'AM_SANITY_CHECK' => 1,
+                        '_AM_PROG_TAR' => 1,
+                        'm4_pattern_forbid' => 1,
+                        'AM_RUN_LOG' => 1,
+                        'AM_MISSING_HAS_RUN' => 1,
+                        'AM_AUX_DIR_EXPAND' => 1,
+                        'AM_PROG_INSTALL_SH' => 1,
+                        'AU_DEFUN' => 1,
+                        'AC_DEFUN' => 1,
+                        'AC_CONFIG_MACRO_DIR_TRACE' => 1,
+                        'AM_CONDITIONAL' => 1,
+                        '_AM_AUTOCONF_VERSION' => 1,
+                        '_AC_AM_CONFIG_HEADER_HOOK' => 1,
+                        'AC_DEFUN_ONCE' => 1,
+                        'AM_DEP_TRACK' => 1,
+                        '_AM_OUTPUT_DEPENDENCY_COMMANDS' => 1,
                         'AM_MAKE_INCLUDE' => 1,
+                        'AM_SUBST_NOTMAKE' => 1,
                         '_AM_CONFIG_MACRO_DIRS' => 1,
+                        '_AM_SET_OPTIONS' => 1,
+                        'AC_CONFIG_MACRO_DIR' => 1,
+                        'm4_include' => 1,
+                        '_AM_IF_OPTION' => 1,
                         'm4_pattern_allow' => 1,
-                        'AM_SET_CURRENT_AUTOMAKE_VERSION' => 1,
                         'AM_SET_DEPDIR' => 1,
-                        '_AM_SET_OPTIONS' => 1,
-                        'AM_SILENT_RULES' => 1,
+                        '_AM_PROG_CC_C_O' => 1,
                         'AM_INIT_AUTOMAKE' => 1,
-                        'AM_PROG_INSTALL_SH' => 1,
-                        '_AM_SET_OPTION' => 1,
-                        'AM_CONDITIONAL' => 1,
-                        'AU_DEFUN' => 1,
-                        '_m4_warn' => 1,
-                        'AM_SANITY_CHECK' => 1,
-                        'AM_SET_LEADING_DOT' => 1,
-                        'AM_AUX_DIR_EXPAND' => 1,
+                        'AM_SILENT_RULES' => 1,
                         'AM_PROG_INSTALL_STRIP' => 1,
-                        '_AM_OUTPUT_DEPENDENCY_COMMANDS' => 1,
-                        '_AC_AM_CONFIG_HEADER_HOOK' => 1,
+                        '_AM_SUBST_NOTMAKE' => 1,
+                        'AM_SET_LEADING_DOT' => 1,
+                        '_AM_MANGLE_OPTION' => 1,
+                        '_AM_SET_OPTION' => 1,
                         '_AM_DEPENDENCIES' => 1,
-                        'include' => 1,
-                        'AM_RUN_LOG' => 1,
                         'AM_AUTOMAKE_VERSION' => 1,
-                        '_AM_SUBST_NOTMAKE' => 1,
-                        '_AM_PROG_CC_C_O' => 1,
                         'AM_OUTPUT_DEPENDENCY_COMMANDS' => 1,
-                        'AC_CONFIG_MACRO_DIR' => 1,
-                        'AM_MISSING_PROG' => 1,
-                        'AC_DEFUN_ONCE' => 1,
-                        '_AM_PROG_TAR' => 1,
-                        'AM_PROG_CC_C_O' => 1,
-                        '_AM_AUTOCONF_VERSION' => 1,
-                        'AM_DEP_TRACK' => 1,
-                        '_AM_IF_OPTION' => 1,
-                        'AM_MISSING_HAS_RUN' => 1,
-                        'AM_SUBST_NOTMAKE' => 1,
-                        'AC_CONFIG_MACRO_DIR_TRACE' => 1,
-                        'AC_DEFUN' => 1,
-                        'm4_pattern_forbid' => 1,
-                        '_AM_MANGLE_OPTION' => 1
+                        'include' => 1,
+                        'AM_SET_CURRENT_AUTOMAKE_VERSION' => 1,
+                        '_m4_warn' => 1,
+                        'AM_PROG_CC_C_O' => 1
                       }
                     ], 'Autom4te::Request' ),
              bless( [
                         'configure.ac'
                       ],
                       {
-                        'AM_MAKEFILE_INCLUDE' => 1,
-                        'AC_CONFIG_LINKS' => 1,
-                        'AC_CONFIG_SUBDIRS' => 1,
-                        'AM_AUTOMAKE_VERSION' => 1,
+                        '_m4_warn' => 1,
+                        'include' => 1,
+                        'LT_CONFIG_LTDL_DIR' => 1,
                         'AM_PROG_MOC' => 1,
-                        'AC_CONFIG_LIBOBJ_DIR' => 1,
+                        'AC_PROG_LIBTOOL' => 1,
+                        'AC_CANONICAL_TARGET' => 1,
+                        'AC_FC_PP_DEFINE' => 1,
+                        'AM_AUTOMAKE_VERSION' => 1,
+                        'AM_SILENT_RULES' => 1,
+                        'AM_PROG_F77_C_O' => 1,
+                        'AM_EXTRA_RECURSIVE_TARGETS' => 1,
+                        'AM_PATH_GUILE' => 1,
                         'LT_SUPPORTED_TAG' => 1,
+                        '_AM_COND_IF' => 1,
+                        'm4_sinclude' => 1,
+                        'AM_XGETTEXT_OPTION' => 1,
                         'AM_MAINTAINER_MODE' => 1,
-                        'AM_PROG_CC_C_O' => 1,
-                        'AM_NLS' => 1,
-                        'AC_CANONICAL_SYSTEM' => 1,
-                        'LT_CONFIG_LTDL_DIR' => 1,
-                        'm4_pattern_forbid' => 1,
-                        '_AM_COND_ELSE' => 1,
-                        'm4_include' => 1,
-                        'AC_SUBST_TRACE' => 1,
-                        'AC_SUBST' => 1,
+                        'AC_CONFIG_HEADERS' => 1,
+                        'AM_MAKEFILE_INCLUDE' => 1,
                         '_AM_MAKEFILE_INCLUDE' => 1,
-                        'AC_REQUIRE_AUX_FILE' => 1,
-                        'AM_ENABLE_MULTILIB' => 1,
-                        'm4_pattern_allow' => 1,
-                        'AM_GNU_GETTEXT_INTL_SUBDIR' => 1,
+                        'AC_CONFIG_LINKS' => 1,
+                        'AM_GNU_GETTEXT' => 1,
+                        'AC_CANONICAL_BUILD' => 1,
+                        'AC_INIT' => 1,
+                        'm4_pattern_forbid' => 1,
+                        'sinclude' => 1,
+                        'AC_CONFIG_SUBDIRS' => 1,
                         'AC_CANONICAL_HOST' => 1,
-                        '_AM_COND_IF' => 1,
-                        'AM_PROG_CXX_C_O' => 1,
-                        'AC_CONFIG_FILES' => 1,
-                        'AC_CANONICAL_TARGET' => 1,
-                        'AC_CONFIG_HEADERS' => 1,
-                        'AM_INIT_AUTOMAKE' => 1,
-                        'AM_POT_TOOLS' => 1,
-                        'AM_CONDITIONAL' => 1,
-                        '_m4_warn' => 1,
-                        'AM_PROG_MKDIR_P' => 1,
-                        'AM_PROG_FC_C_O' => 1,
-                        'AC_FC_FREEFORM' => 1,
+                        '_AM_COND_ELSE' => 1,
                         'AC_CONFIG_AUX_DIR' => 1,
                         'AC_FC_SRCEXT' => 1,
-                        'include' => 1,
-                        '_AM_SUBST_NOTMAKE' => 1,
+                        'AM_PROG_CC_C_O' => 1,
+                        'AC_SUBST_TRACE' => 1,
+                        'AC_DEFINE_TRACE_LITERAL' => 1,
+                        'AM_PROG_MKDIR_P' => 1,
                         '_LT_AC_TAGCONFIG' => 1,
-                        'AC_PROG_LIBTOOL' => 1,
-                        'AC_FC_PP_SRCEXT' => 1,
-                        'sinclude' => 1,
-                        'AC_FC_PP_DEFINE' => 1,
-                        'AC_LIBSOURCE' => 1,
+                        'AM_INIT_AUTOMAKE' => 1,
                         '_AM_COND_ENDIF' => 1,
-                        'AM_PATH_GUILE' => 1,
+                        '_AM_SUBST_NOTMAKE' => 1,
                         'AH_OUTPUT' => 1,
-                        'AM_PROG_F77_C_O' => 1,
-                        'AC_INIT' => 1,
-                        'm4_sinclude' => 1,
-                        'AM_EXTRA_RECURSIVE_TARGETS' => 1,
+                        'AM_PROG_CXX_C_O' => 1,
+                        'AC_CANONICAL_SYSTEM' => 1,
+                        'm4_pattern_allow' => 1,
+                        'm4_include' => 1,
+                        'AM_NLS' => 1,
+                        'AC_CONFIG_LIBOBJ_DIR' => 1,
+                        'AM_POT_TOOLS' => 1,
                         'LT_INIT' => 1,
-                        'AM_SILENT_RULES' => 1,
-                        'AC_CANONICAL_BUILD' => 1,
-                        'AM_XGETTEXT_OPTION' => 1,
-                        'AM_GNU_GETTEXT' => 1,
+                        'AM_PROG_FC_C_O' => 1,
                         'AM_PROG_AR' => 1,
-                        'AC_DEFINE_TRACE_LITERAL' => 1
+                        'AM_GNU_GETTEXT_INTL_SUBDIR' => 1,
+                        'AC_REQUIRE_AUX_FILE' => 1,
+                        'AM_CONDITIONAL' => 1,
+                        'AC_LIBSOURCE' => 1,
+                        'AC_FC_PP_SRCEXT' => 1,
+                        'AM_ENABLE_MULTILIB' => 1,
+                        'AC_SUBST' => 1,
+                        'AC_FC_FREEFORM' => 1,
+                        'AC_CONFIG_FILES' => 1
                       }
                     ], 'Autom4te::Request' )
            );
index 6429eb4..4a604d8 100644 (file)
@@ -389,3 +389,25 @@ config.status:1146: cd src       && sed -e '/# am--include-marker/d' makefile
 make[1]: Entering directory '/home/morpheus/subu_land/subu/src'
 make[1]: Leaving directory '/home/morpheus/subu_land/subu/src'
 config.status:1151: $? = 0
+
+## ---------------------- ##
+## Running config.status. ##
+## ---------------------- ##
+
+This file was extended by mk-subu-0 config.status 1.0, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
+
+  CONFIG_FILES    = 
+  CONFIG_HEADERS  = 
+  CONFIG_LINKS    = 
+  CONFIG_COMMANDS = 
+  $ ./config.status src/makefile depfiles
+
+on manorhouse
+
+config.status:840: creating src/makefile
+config.status:1069: executing depfiles commands
+config.status:1146: cd src       && sed -e '/# am--include-marker/d' makefile         | make -f - am--depfiles
+make[1]: Entering directory '/home/morpheus/subu_land/subu/src'
+make[1]: Leaving directory '/home/morpheus/subu_land/subu/src'
+config.status:1151: $? = 0
diff --git a/src/.deps/dbprintf.aux.Po b/src/.deps/dbprintf.aux.Po
new file mode 100644 (file)
index 0000000..29100fb
--- /dev/null
@@ -0,0 +1,59 @@
+dbprintf.aux.o: dbprintf.aux.c /usr/include/stdc-predef.h \
+ /usr/lib/gcc/x86_64-redhat-linux/8/include/stdarg.h /usr/include/stdio.h \
+ /usr/include/bits/libc-header-start.h /usr/include/features.h \
+ /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \
+ /usr/include/bits/long-double.h /usr/include/gnu/stubs.h \
+ /usr/include/gnu/stubs-64.h \
+ /usr/lib/gcc/x86_64-redhat-linux/8/include/stddef.h \
+ /usr/include/bits/types.h /usr/include/bits/typesizes.h \
+ /usr/include/bits/types/__fpos_t.h /usr/include/bits/types/__mbstate_t.h \
+ /usr/include/bits/types/__fpos64_t.h /usr/include/bits/types/__FILE.h \
+ /usr/include/bits/types/FILE.h /usr/include/bits/types/struct_FILE.h \
+ /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+ /usr/include/bits/stdio.h dbprintf.aux.h
+
+/usr/include/stdc-predef.h:
+
+/usr/lib/gcc/x86_64-redhat-linux/8/include/stdarg.h:
+
+/usr/include/stdio.h:
+
+/usr/include/bits/libc-header-start.h:
+
+/usr/include/features.h:
+
+/usr/include/sys/cdefs.h:
+
+/usr/include/bits/wordsize.h:
+
+/usr/include/bits/long-double.h:
+
+/usr/include/gnu/stubs.h:
+
+/usr/include/gnu/stubs-64.h:
+
+/usr/lib/gcc/x86_64-redhat-linux/8/include/stddef.h:
+
+/usr/include/bits/types.h:
+
+/usr/include/bits/typesizes.h:
+
+/usr/include/bits/types/__fpos_t.h:
+
+/usr/include/bits/types/__mbstate_t.h:
+
+/usr/include/bits/types/__fpos64_t.h:
+
+/usr/include/bits/types/__FILE.h:
+
+/usr/include/bits/types/FILE.h:
+
+/usr/include/bits/types/struct_FILE.h:
+
+/usr/include/bits/stdio_lim.h:
+
+/usr/include/bits/sys_errlist.h:
+
+/usr/include/bits/stdio.h:
+
+dbprintf.aux.h:
index d44351a..0e84d00 100644 (file)
@@ -46,7 +46,8 @@ dispatch.lib.o: dispatch.lib.c /usr/include/stdc-predef.h \
  /usr/include/linux/errno.h /usr/include/asm/errno.h \
  /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
  /usr/include/bits/types/error_t.h local_common.h ../config.h \
- /usr/lib/gcc/x86_64-redhat-linux/8/include/stdbool.h dispatch.lib.h
+ /usr/lib/gcc/x86_64-redhat-linux/8/include/stdbool.h dbprintf.aux.h \
+ dispatch.lib.h
 
 /usr/include/stdc-predef.h:
 
@@ -228,4 +229,6 @@ local_common.h:
 
 /usr/lib/gcc/x86_64-redhat-linux/8/include/stdbool.h:
 
+dbprintf.aux.h:
+
 dispatch.lib.h:
index d8a0f45..9a5394d 100644 (file)
@@ -32,8 +32,8 @@ dispatch_useradd.lib.o: dispatch_useradd.lib.c /usr/include/stdc-predef.h \
  /usr/include/linux/errno.h /usr/include/asm/errno.h \
  /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
  local_common.h ../config.h \
- /usr/lib/gcc/x86_64-redhat-linux/8/include/stdbool.h dispatch.lib.h \
- dispatch_useradd.lib.h /usr/include/pwd.h
+ /usr/lib/gcc/x86_64-redhat-linux/8/include/stdbool.h dbprintf.aux.h \
+ dispatch.lib.h dispatch_useradd.lib.h /usr/include/pwd.h
 
 /usr/include/stdc-predef.h:
 
@@ -163,6 +163,8 @@ local_common.h:
 
 /usr/lib/gcc/x86_64-redhat-linux/8/include/stdbool.h:
 
+dbprintf.aux.h:
+
 dispatch.lib.h:
 
 dispatch_useradd.lib.h:
index 133ce51..2e62d51 100644 (file)
@@ -35,7 +35,7 @@ subu-mk-0.lib.o: subu-mk-0.lib.c /usr/include/stdc-predef.h \
  /usr/include/string.h /usr/include/strings.h /usr/include/sys/stat.h \
  /usr/include/bits/stat.h /usr/include/bits/statx.h dispatch.lib.h \
  local_common.h ../config.h \
- /usr/lib/gcc/x86_64-redhat-linux/8/include/stdbool.h \
+ /usr/lib/gcc/x86_64-redhat-linux/8/include/stdbool.h dbprintf.aux.h \
  dispatch_useradd.lib.h subu-mk-0.lib.h
 
 /usr/include/stdc-predef.h:
@@ -174,6 +174,8 @@ local_common.h:
 
 /usr/lib/gcc/x86_64-redhat-linux/8/include/stdbool.h:
 
+dbprintf.aux.h:
+
 dispatch_useradd.lib.h:
 
 subu-mk-0.lib.h:
diff --git a/src/dbprintf.aux.c b/src/dbprintf.aux.c
new file mode 100644 (file)
index 0000000..edea747
--- /dev/null
@@ -0,0 +1,13 @@
+
+#include <stdarg.h>
+#include <stdio.h>
+#include "dbprintf.aux.h"
+
+int dbprintf(const char *format, ...){
+  va_list args;
+  va_start(args,format);  
+  int ret = vfprintf(stdout, format, args);
+  fflush(stdout);
+  va_end(args);
+  return ret;
+}
diff --git a/src/dbprintf.aux.h b/src/dbprintf.aux.h
new file mode 100644 (file)
index 0000000..967fdae
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef DBPRINTF_AUX_H
+#define DBPRINTF_AUX_H
+
+int dbprintf(const char *format, ...);
+
+#endif
diff --git a/src/dbprintf.aux.o b/src/dbprintf.aux.o
new file mode 100644 (file)
index 0000000..1dc581d
Binary files /dev/null and b/src/dbprintf.aux.o differ
index dd1fa0e..d4b9c4a 100644 (file)
@@ -37,6 +37,15 @@ int dispatch(char **argv, char **envp){
     fprintf(stderr, "argv[0] null. Null command passed into dispatch().\n");
     return -1;
   }
+  #ifdef DEBUG
+    dbprintf("dispatching:");
+    char **apt = argv;
+    while( apt ){
+      dbprintf(" %s",*apt);
+    apt++;
+    }
+    dbprintf("\n");
+  #endif
   char *command = argv[0];
   pid_t pid = fork();
   if( pid == -1 ){
diff --git a/src/dispatch.lib.o b/src/dispatch.lib.o
new file mode 100644 (file)
index 0000000..548fd25
Binary files /dev/null and b/src/dispatch.lib.o differ
diff --git a/src/dispatch_useradd.lib.o b/src/dispatch_useradd.lib.o
new file mode 100644 (file)
index 0000000..a3b50a1
Binary files /dev/null and b/src/dispatch_useradd.lib.o differ
index b9beb20..5f656b2 100644 (file)
@@ -3,14 +3,11 @@
 
 #include "config.h"
 #include <stdbool.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include "dbprintf.aux.h"
 
 #define DEBUG
-
-// wstatus is the exec'ed program return code, which we only allow 16 bits
-// so as to also have exec routine error codes
-#define WSTATUS_MASK ((1 << 16) - 1)
-
 typedef unsigned int uint;
 
-
 #endif
index ad6d48b..4beb3f4 100644 (file)
@@ -99,8 +99,9 @@ CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)"
 PROGRAMS = $(bin_PROGRAMS)
-am_subu_mk_0_OBJECTS = subu-mk-0.cli.$(OBJEXT) subu-mk-0.lib.$(OBJEXT) \
-       dispatch.lib.$(OBJEXT) dispatch_useradd.lib.$(OBJEXT)
+am_subu_mk_0_OBJECTS = dbprintf.aux.$(OBJEXT) subu-mk-0.cli.$(OBJEXT) \
+       subu-mk-0.lib.$(OBJEXT) dispatch.lib.$(OBJEXT) \
+       dispatch_useradd.lib.$(OBJEXT)
 subu_mk_0_OBJECTS = $(am_subu_mk_0_OBJECTS)
 subu_mk_0_LDADD = $(LDADD)
 AM_V_P = $(am__v_P_$(V))
@@ -118,7 +119,8 @@ am__v_at_1 =
 DEFAULT_INCLUDES = -I. -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__maybe_remake_depfiles = depfiles
-am__depfiles_remade = ./$(DEPDIR)/dispatch.lib.Po \
+am__depfiles_remade = ./$(DEPDIR)/dbprintf.aux.Po \
+       ./$(DEPDIR)/dispatch.lib.Po \
        ./$(DEPDIR)/dispatch_useradd.lib.Po \
        ./$(DEPDIR)/subu-mk-0.cli.Po ./$(DEPDIR)/subu-mk-0.lib.Po
 am__mv = mv -f
@@ -247,6 +249,7 @@ top_build_prefix = ../
 top_builddir = ..
 top_srcdir = ..
 subu_mk_0_SOURCES = \
+       dbprintf.aux.c\
        subu-mk-0.cli.c\
        subu-mk-0.lib.c\
        dispatch.lib.c\
@@ -338,6 +341,7 @@ mostlyclean-compile:
 distclean-compile:
        -rm -f *.tab.c
 
+include ./$(DEPDIR)/dbprintf.aux.Po # am--include-marker
 include ./$(DEPDIR)/dispatch.lib.Po # am--include-marker
 include ./$(DEPDIR)/dispatch_useradd.lib.Po # am--include-marker
 include ./$(DEPDIR)/subu-mk-0.cli.Po # am--include-marker
@@ -490,7 +494,8 @@ clean: clean-am
 clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
 
 distclean: distclean-am
-               -rm -f ./$(DEPDIR)/dispatch.lib.Po
+               -rm -f ./$(DEPDIR)/dbprintf.aux.Po
+       -rm -f ./$(DEPDIR)/dispatch.lib.Po
        -rm -f ./$(DEPDIR)/dispatch_useradd.lib.Po
        -rm -f ./$(DEPDIR)/subu-mk-0.cli.Po
        -rm -f ./$(DEPDIR)/subu-mk-0.lib.Po
@@ -539,7 +544,8 @@ install-ps-am:
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
-               -rm -f ./$(DEPDIR)/dispatch.lib.Po
+               -rm -f ./$(DEPDIR)/dbprintf.aux.Po
+       -rm -f ./$(DEPDIR)/dispatch.lib.Po
        -rm -f ./$(DEPDIR)/dispatch_useradd.lib.Po
        -rm -f ./$(DEPDIR)/subu-mk-0.cli.Po
        -rm -f ./$(DEPDIR)/subu-mk-0.lib.Po
index 98a91ac..02f1612 100644 (file)
@@ -1,5 +1,6 @@
 bin_PROGRAMS=subu-mk-0
 subu_mk_0_SOURCES=\
+       dbprintf.aux.c\
        subu-mk-0.cli.c\
        subu-mk-0.lib.c\
        dispatch.lib.c\
index bf9fde3..d61fa61 100644 (file)
@@ -99,8 +99,9 @@ CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)"
 PROGRAMS = $(bin_PROGRAMS)
-am_subu_mk_0_OBJECTS = subu-mk-0.cli.$(OBJEXT) subu-mk-0.lib.$(OBJEXT) \
-       dispatch.lib.$(OBJEXT) dispatch_useradd.lib.$(OBJEXT)
+am_subu_mk_0_OBJECTS = dbprintf.aux.$(OBJEXT) subu-mk-0.cli.$(OBJEXT) \
+       subu-mk-0.lib.$(OBJEXT) dispatch.lib.$(OBJEXT) \
+       dispatch_useradd.lib.$(OBJEXT)
 subu_mk_0_OBJECTS = $(am_subu_mk_0_OBJECTS)
 subu_mk_0_LDADD = $(LDADD)
 AM_V_P = $(am__v_P_@AM_V@)
@@ -118,7 +119,8 @@ am__v_at_1 =
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__maybe_remake_depfiles = depfiles
-am__depfiles_remade = ./$(DEPDIR)/dispatch.lib.Po \
+am__depfiles_remade = ./$(DEPDIR)/dbprintf.aux.Po \
+       ./$(DEPDIR)/dispatch.lib.Po \
        ./$(DEPDIR)/dispatch_useradd.lib.Po \
        ./$(DEPDIR)/subu-mk-0.cli.Po ./$(DEPDIR)/subu-mk-0.lib.Po
 am__mv = mv -f
@@ -247,6 +249,7 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 subu_mk_0_SOURCES = \
+       dbprintf.aux.c\
        subu-mk-0.cli.c\
        subu-mk-0.lib.c\
        dispatch.lib.c\
@@ -338,6 +341,7 @@ mostlyclean-compile:
 distclean-compile:
        -rm -f *.tab.c
 
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbprintf.aux.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dispatch.lib.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dispatch_useradd.lib.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/subu-mk-0.cli.Po@am__quote@ # am--include-marker
@@ -490,7 +494,8 @@ clean: clean-am
 clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
 
 distclean: distclean-am
-               -rm -f ./$(DEPDIR)/dispatch.lib.Po
+               -rm -f ./$(DEPDIR)/dbprintf.aux.Po
+       -rm -f ./$(DEPDIR)/dispatch.lib.Po
        -rm -f ./$(DEPDIR)/dispatch_useradd.lib.Po
        -rm -f ./$(DEPDIR)/subu-mk-0.cli.Po
        -rm -f ./$(DEPDIR)/subu-mk-0.lib.Po
@@ -539,7 +544,8 @@ install-ps-am:
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
-               -rm -f ./$(DEPDIR)/dispatch.lib.Po
+               -rm -f ./$(DEPDIR)/dbprintf.aux.Po
+       -rm -f ./$(DEPDIR)/dispatch.lib.Po
        -rm -f ./$(DEPDIR)/dispatch_useradd.lib.Po
        -rm -f ./$(DEPDIR)/subu-mk-0.cli.Po
        -rm -f ./$(DEPDIR)/subu-mk-0.lib.Po
index 5f2b8f1..bea2d00 100755 (executable)
@@ -1,7 +1,8 @@
 #!/bin/bash
 # must be run under sudo
+# be sure to cat it before running it, better yet just type this in manually
 #
 
 chown root $1 && \
-chmod u+rsx,u-w,g+rx-s $1
+chmod u+rsx,u-w,go+rx-s-w $1
 
diff --git a/src/subu-mk-0 b/src/subu-mk-0
new file mode 100755 (executable)
index 0000000..0cc6234
Binary files /dev/null and b/src/subu-mk-0 differ
diff --git a/src/subu-mk-0.cli.o b/src/subu-mk-0.cli.o
new file mode 100644 (file)
index 0000000..0cb09fa
Binary files /dev/null and b/src/subu-mk-0.cli.o differ
index 71bac28..caf5535 100644 (file)
@@ -27,13 +27,15 @@ typedef unsigned int uint;
 int subu_mk_0(char *subuname){
 
   //--------------------------------------------------------------------------------
-  // check that we are run from a user account (the masteru) and that we have setuid to root
+  #ifdef DEBUG
+  dbprintf("Checking we are running from a user and are setuid root.\n");
+  #endif
   uid_t uid = getuid();
   uid_t euid = geteuid();
   gid_t gid = getgid();
   gid_t egid = getegid();
   #ifdef DEBUG
-    printf("uid %u, gid %u, euid %u\n", uid, gid, euid);
+  dbprintf("uid %u, gid %u, euid %u egid %u\n", uid, gid, euid, egid);
   #endif
   if( uid == 0 || euid != 0 ){
     fprintf(stderr, "this program must be run setuid root from a user account\n");
@@ -41,12 +43,14 @@ int subu_mk_0(char *subuname){
   }
 
   //--------------------------------------------------------------------------------
-  // who are these people anyway?
   size_t subuname_len;
   char *masteru_name;
   size_t masteru_name_len;
   struct passwd *masteru_pw_record_pt;
   {
+    #ifdef DEBUG
+    dbprintf("looking up masteru_name (i.e. uid %u) in /etc/passwd\n",uid);
+    #endif
     // subuname is the first argument passed in
     // verify that subuname is legal!  --> code goes here ...  
     subuname_len = strlen(subuname);
@@ -55,16 +59,18 @@ int subu_mk_0(char *subuname){
     masteru_name_len = strlen(masteru_name);
   }
   #ifdef DEBUG
-  printf("masteru_name: %s\n", masteru_name);
+  dbprintf("subuname \"%s\" masteru_name: \"%s\"\n", subuname, masteru_name);
   #endif
 
   //--------------------------------------------------------------------------------
-  // build the subuland path
   char *masteru_home;
   size_t masteru_home_len;
   char *subuland;
   size_t subuland_len;
   {
+    #ifdef DEBUG
+    dbprintf("building the subuland path\n");
+    #endif
     masteru_home = masteru_pw_record_pt->pw_dir;
     masteru_home_len = strlen(masteru_home);
     if( masteru_home_len == 0 || masteru_home[0] == '(' ){
@@ -79,14 +85,17 @@ int subu_mk_0(char *subuname){
     subuland_len = masteru_home_len + subuland_extension_len;
   }
   #ifdef DEBUG
-  printf("masteru_home: \"%s\"\n", masteru_home);
-  printf("The path to subuland: \"%s\"\n", subuland);
+  dbprintf("masteru_home: \"%s\"\n", masteru_home);
+  dbprintf("The path to subuland: \"%s\".\n", subuland);
   #endif
 
   //--------------------------------------------------------------------------------
   // Just because masteru_home is referenced in /etc/passwd does not mean it exists.
   // We also require that the subuland sub directory exists.
   {
+    #ifdef DEBUG
+    dbprintf("checking that masteru_home and subuland exist\n");
+    #endif
     struct stat st;
     if( stat(masteru_home, &st) == -1) {
       fprintf(stderr, "Strange, masteru home does not exist, \"%s\".", masteru_home);
@@ -105,6 +114,9 @@ int subu_mk_0(char *subuname){
   char *subuhome;
   size_t subuhome_len;
   {
+    #ifdef DEBUG
+    dbprintf("making the name for subuhome\n");
+    #endif
     subuhome_len = subuland_len + subuname_len;
     subuhome = (char *)malloc(subuhome_len + 1);
     if( !subuhome ){
@@ -116,16 +128,15 @@ int subu_mk_0(char *subuname){
     strcpy (subuhome + subuland_len, subuname);
   }
   #ifdef DEBUG
-  printf("subuhome: %s\n", subuhome);
+  dbprintf("subuhome %s\n", subuhome);
   #endif
 
   /*--------------------------------------------------------------------------------
-    make the subservient user account
-
     We need to add execute access rights to masteru home and subuland so that
     the subu user can cd to subuhome.
 
-    Ok to specify the new home directory to useradd, note this from the man page:
+    Ok to specify the new home directory in useradd, because it doesn't make it.
+    From the man page:
 
            -d, --home-dir HOME_DIR The new user will be created using HOME_DIR
            as the value for the user's login directory. ... The directory HOME_DIR
@@ -134,8 +145,12 @@ int subu_mk_0(char *subuname){
   uid_t subuuid;
   gid_t subugid;
   {
+    #ifdef DEBUG
+    dbprintf("making subu\n");
+    #endif
+    char *command = "/usr/sbin/useradd";
     char *argv[5];
-    argv[0] = "/usr/bin/useradd";
+    argv[0] = command;
     argv[1] = subuname;
     argv[2] = "-d";
     argv[3] = subuhome;
@@ -152,20 +167,23 @@ int subu_mk_0(char *subuname){
     }
     subuuid = ret.pw_record->pw_uid;
     subugid = ret.pw_record->pw_gid;
+    #ifdef DEBUG
+    dbprintf("subu made without errors\n", command, subuname, subuhome);
+    #endif
   }  
   
   //--------------------------------------------------------------------------------
-  // give subu x access to masteru and subuland
-  //   setfacl -m u:subuname:x masteru
-  //   setfacl -m u:subuname:x masteru/subuland
   {
+    #ifdef DEBUG
+    dbprintf("give subu x access to masteru and subuland\n");
+    #endif
+    char *command = "/usr/bin/setfacl";
     char access[2 + subuname_len + 2 + 1];
     strcpy(access, "u:");
     strcpy(access + 2, subuname);
     strcpy(access + 2 + subuname_len, ":x");
-
     char *argv[5];
-    argv[0] = "/usr/bin/setfacl";
+    argv[0] = command;
     argv[1] = "-m";
     argv[2] = access;
     argv[3] = masteru_home;
@@ -178,11 +196,21 @@ int subu_mk_0(char *subuname){
       free(subuhome);
       return ERR_SETFACL;
     }
+    argv[3] = subuland;
+    if( dispatch(argv, envp) == -1 ){
+      fprintf(stderr, "'setfacl -m u:%s:x %s' returned an error.\n", subuname, subuland);
+      free(subuland);
+      free(subuhome);
+      return ERR_SETFACL;
+    }
   }
 
   //--------------------------------------------------------------------------------
   // create subuhome directory
   {
+    #ifdef DEBUG
+    dbprintf("mkdir(%s, 0x0700)\n", subuhome);
+    #endif
     int ret = mkdir(subuhome, 0x0700);
     if( ret == -1 ){
       perror("subu_mk_0");
@@ -200,10 +228,11 @@ int subu_mk_0(char *subuname){
   }
 
   //--------------------------------------------------------------------------------
-  // give masteru access to subu_home and all descendents.  This is why subu is
-  // said to be subservient.
-  // setfacl -R -m d:u:masteru:rwX,u:masteru:rwX subuhome
   {  
+    #ifdef DEBUG
+    dbprintf("give masteru access to the subuhome/...");
+    #endif
+    char *command = "/usr/bin/setfacl";
     char access[4 + masteru_name_len + 7 + masteru_name_len + 5 + subuhome_len + 1];
     strcpy(access, "d:u:");
     strcpy(access + 4, masteru_name);
@@ -211,9 +240,8 @@ int subu_mk_0(char *subuname){
     strcpy(access + 4 + masteru_name_len + 7, masteru_name);
     strcpy(access + 4 + masteru_name_len + 7 + masteru_name_len, ":rwX ");
     strcpy(access + 4 + masteru_name_len + 7 + masteru_name_len + 5, subuhome);
-
     char *argv[6];
-    argv[0] = "/usr/bin/setfacl";
+    argv[0] = command;
     argv[1] = "-R";  // just in case the dir already existed with stuff in it
     argv[2] = "-m";
     argv[3] = access;
@@ -236,6 +264,9 @@ int subu_mk_0(char *subuname){
     }
   }
 
+  #ifdef DEBUG
+  dbprintf("finished subu-mk-0(%s) without error\n", subuname);
+  #endif
   free(subuland);
   free(subuhome);
   return 0;
diff --git a/src/subu-mk-0.lib.o b/src/subu-mk-0.lib.o
new file mode 100644 (file)
index 0000000..045b335
Binary files /dev/null and b/src/subu-mk-0.lib.o differ
diff --git a/try/example.txt b/try/example.txt
new file mode 100644 (file)
index 0000000..9820a99
--- /dev/null
@@ -0,0 +1,24 @@
+2019-02-12T18:46:27Z user@host§~/subu_land/subu/try/useradd_probs§
+> ./user-mk temp6
+Checking we are running from a user and are setuid root.
+uid 49972, gid 49972, euid 0 egid 49972
+yes, uid is not zero, and euid is zero, so we are setuid to the root user.
+making the home dir path
+home dir path: "/home/temp6"
+dispatching useradd to create the user
+dispatching:
+arg: 0x7ffebf3f6800 /usr/sbin/useradd
+arg: 0x7ffebf3f6808 temp6
+arg: 0x7ffebf3f6810 -d
+arg: 0x7ffebf3f6818 /home/temp6
+
+sss_cache must be run as root
+useradd: sss_cache exited with status 1
+useradd: Failed to flush the sssd cache.
+sss_cache must be run as root
+useradd: sss_cache exited with status 1
+useradd: Failed to flush the sssd cache.
+mkdir(/home/temp6, 0x0700)
+user-mk: File exists
+
+2019-02-12T18:46:33Z user@host§~/subu_land/subu/try/useradd_probs§