From: Thomas Walker Lynch Date: Sun, 10 Feb 2019 00:14:32 +0000 (+0100) Subject: checkpoint X-Git-Url: https://git.reasoningtechnology.com/style/static/git-logo.png?a=commitdiff_plain;h=68429a16ecd11ca0e3b03cc7c558cfeeef0b7bc0;p=subu checkpoint --- diff --git a/autom4te.cache/requests b/autom4te.cache/requests index 9eefa2d..b344d1e 100644 --- a/autom4te.cache/requests +++ b/autom4te.cache/requests @@ -34,47 +34,47 @@ 'configure.ac' ], { - '_AC_AM_CONFIG_HEADER_HOOK' => 1, 'AC_CONFIG_MACRO_DIR' => 1, - 'AM_CONDITIONAL' => 1, + 'AM_AUX_DIR_EXPAND' => 1, + 'AC_DEFUN' => 1, + '_AM_CONFIG_MACRO_DIRS' => 1, 'AM_AUTOMAKE_VERSION' => 1, - 'AM_SET_DEPDIR' => 1, + 'AM_SANITY_CHECK' => 1, + 'AM_MAKE_INCLUDE' => 1, + 'AM_SET_LEADING_DOT' => 1, '_AM_PROG_TAR' => 1, + 'AM_PROG_INSTALL_STRIP' => 1, + '_AM_DEPENDENCIES' => 1, + 'AM_RUN_LOG' => 1, + 'AM_PROG_INSTALL_SH' => 1, + 'AM_PROG_CC_C_O' => 1, + 'AM_INIT_AUTOMAKE' => 1, + 'AM_SET_CURRENT_AUTOMAKE_VERSION' => 1, + 'AC_DEFUN_ONCE' => 1, + 'AM_CONDITIONAL' => 1, + '_AM_SET_OPTION' => 1, + 'm4_pattern_forbid' => 1, + 'AU_DEFUN' => 1, + 'include' => 1, + '_AM_IF_OPTION' => 1, + '_AM_MANGLE_OPTION' => 1, '_m4_warn' => 1, - 'AM_AUX_DIR_EXPAND' => 1, + 'AM_DEP_TRACK' => 1, 'AM_SILENT_RULES' => 1, - 'AC_DEFUN_ONCE' => 1, - 'AM_PROG_INSTALL_STRIP' => 1, + '_AM_PROG_CC_C_O' => 1, 'm4_include' => 1, - '_AM_OUTPUT_DEPENDENCY_COMMANDS' => 1, - 'AC_CONFIG_MACRO_DIR_TRACE' => 1, 'AM_MISSING_HAS_RUN' => 1, - 'AM_SET_CURRENT_AUTOMAKE_VERSION' => 1, '_AM_SUBST_NOTMAKE' => 1, - 'AM_RUN_LOG' => 1, - 'AU_DEFUN' => 1, - 'AM_PROG_INSTALL_SH' => 1, - 'm4_pattern_allow' => 1, '_AM_AUTOCONF_VERSION' => 1, - 'AC_DEFUN' => 1, - '_AM_CONFIG_MACRO_DIRS' => 1, + '_AM_OUTPUT_DEPENDENCY_COMMANDS' => 1, + '_AC_AM_CONFIG_HEADER_HOOK' => 1, 'AM_OUTPUT_DEPENDENCY_COMMANDS' => 1, - 'AM_MAKE_INCLUDE' => 1, - 'AM_DEP_TRACK' => 1, - '_AM_IF_OPTION' => 1, - 'AM_MISSING_PROG' => 1, - 'include' => 1, + 'AM_SET_DEPDIR' => 1, + 'AC_CONFIG_MACRO_DIR_TRACE' => 1, + 'm4_pattern_allow' => 1, '_AM_SET_OPTIONS' => 1, - 'm4_pattern_forbid' => 1, - 'AM_SET_LEADING_DOT' => 1, 'AM_SUBST_NOTMAKE' => 1, - '_AM_PROG_CC_C_O' => 1, - 'AM_SANITY_CHECK' => 1, - '_AM_MANGLE_OPTION' => 1, - '_AM_SET_OPTION' => 1, - 'AM_PROG_CC_C_O' => 1, - 'AM_INIT_AUTOMAKE' => 1, - '_AM_DEPENDENCIES' => 1 + 'AM_MISSING_PROG' => 1 } ], 'Autom4te::Request' ), bless( [ @@ -89,65 +89,65 @@ 'configure.ac' ], { - 'AC_CONFIG_SUBDIRS' => 1, + 'AM_PROG_CXX_C_O' => 1, + 'AM_MAINTAINER_MODE' => 1, + 'm4_pattern_allow' => 1, 'AC_CONFIG_HEADERS' => 1, - '_AM_COND_IF' => 1, - 'AC_CONFIG_LINKS' => 1, - 'LT_CONFIG_LTDL_DIR' => 1, + 'AC_FC_PP_SRCEXT' => 1, + 'LT_INIT' => 1, + 'm4_include' => 1, + 'AC_INIT' => 1, + '_AM_MAKEFILE_INCLUDE' => 1, + '_m4_warn' => 1, + 'AM_SILENT_RULES' => 1, + 'include' => 1, + 'AM_MAKEFILE_INCLUDE' => 1, 'sinclude' => 1, - 'AC_FC_PP_DEFINE' => 1, - '_LT_AC_TAGCONFIG' => 1, + 'AC_CANONICAL_TARGET' => 1, 'AM_PATH_GUILE' => 1, + 'm4_pattern_forbid' => 1, + 'AC_REQUIRE_AUX_FILE' => 1, + '_AM_COND_ENDIF' => 1, 'AM_CONDITIONAL' => 1, - 'AC_PROG_LIBTOOL' => 1, - 'AM_POT_TOOLS' => 1, - 'AM_AUTOMAKE_VERSION' => 1, - 'AM_MAKEFILE_INCLUDE' => 1, + '_LT_AC_TAGCONFIG' => 1, 'AC_CONFIG_FILES' => 1, - '_AM_MAKEFILE_INCLUDE' => 1, - 'AM_PROG_MKDIR_P' => 1, - 'AM_NLS' => 1, - 'AC_REQUIRE_AUX_FILE' => 1, - 'AC_CANONICAL_TARGET' => 1, - 'AM_INIT_AUTOMAKE' => 1, + 'AC_CANONICAL_HOST' => 1, 'AC_FC_FREEFORM' => 1, - 'AM_PROG_FC_C_O' => 1, - 'AC_FC_SRCEXT' => 1, - 'AM_PROG_F77_C_O' => 1, - 'AM_PROG_AR' => 1, - 'm4_include' => 1, - 'AH_OUTPUT' => 1, - 'AM_XGETTEXT_OPTION' => 1, - 'm4_sinclude' => 1, - 'AM_ENABLE_MULTILIB' => 1, - 'AM_GNU_GETTEXT' => 1, - '_AM_SUBST_NOTMAKE' => 1, - 'AC_INIT' => 1, - 'AC_CONFIG_LIBOBJ_DIR' => 1, - 'AM_PROG_CXX_C_O' => 1, 'AC_CANONICAL_BUILD' => 1, - 'LT_SUPPORTED_TAG' => 1, + 'AM_PROG_MKDIR_P' => 1, + 'm4_sinclude' => 1, 'AM_GNU_GETTEXT_INTL_SUBDIR' => 1, - 'AC_CANONICAL_SYSTEM' => 1, - 'LT_INIT' => 1, + 'AM_XGETTEXT_OPTION' => 1, + 'AM_EXTRA_RECURSIVE_TARGETS' => 1, + 'AC_DEFINE_TRACE_LITERAL' => 1, + 'AM_NLS' => 1, + '_AM_COND_IF' => 1, + 'LT_SUPPORTED_TAG' => 1, + 'AC_SUBST_TRACE' => 1, '_AM_COND_ELSE' => 1, - '_m4_warn' => 1, - 'AC_CANONICAL_HOST' => 1, - 'AM_SILENT_RULES' => 1, - 'AC_FC_PP_SRCEXT' => 1, - 'AM_MAINTAINER_MODE' => 1, + 'AM_ENABLE_MULTILIB' => 1, + '_AM_SUBST_NOTMAKE' => 1, + 'AH_OUTPUT' => 1, + 'AC_PROG_LIBTOOL' => 1, + 'AM_GNU_GETTEXT' => 1, + 'AM_POT_TOOLS' => 1, 'AC_SUBST' => 1, - 'include' => 1, - 'AM_PROG_MOC' => 1, - 'm4_pattern_forbid' => 1, - 'AC_CONFIG_AUX_DIR' => 1, - 'AM_PROG_CC_C_O' => 1, + 'AC_CONFIG_LIBOBJ_DIR' => 1, 'AC_LIBSOURCE' => 1, - '_AM_COND_ENDIF' => 1, - 'm4_pattern_allow' => 1, - 'AM_EXTRA_RECURSIVE_TARGETS' => 1, - 'AC_SUBST_TRACE' => 1, - 'AC_DEFINE_TRACE_LITERAL' => 1 + 'AC_FC_SRCEXT' => 1, + 'AM_PROG_FC_C_O' => 1, + 'LT_CONFIG_LTDL_DIR' => 1, + 'AM_PROG_CC_C_O' => 1, + 'AC_FC_PP_DEFINE' => 1, + 'AM_INIT_AUTOMAKE' => 1, + 'AM_PROG_F77_C_O' => 1, + 'AC_CONFIG_AUX_DIR' => 1, + 'AM_AUTOMAKE_VERSION' => 1, + 'AC_CONFIG_LINKS' => 1, + 'AC_CONFIG_SUBDIRS' => 1, + 'AC_CANONICAL_SYSTEM' => 1, + 'AM_PROG_AR' => 1, + 'AM_PROG_MOC' => 1 } ], 'Autom4te::Request' ) ); diff --git a/config.h.in~ b/config.h.in~ new file mode 100644 index 0000000..dd3b02c --- /dev/null +++ b/config.h.in~ @@ -0,0 +1,25 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Version number of package */ +#undef VERSION diff --git a/config.log b/config.log index fb37826..e889fa2 100644 --- a/config.log +++ b/config.log @@ -4,7 +4,7 @@ running configure, to aid debugging if configure makes a mistake. It was created by mk-subu-0 configure 1.0, which was generated by GNU Autoconf 2.69. Invocation command line was - $ ./configure + $ ./configure --no-create --no-recursion ## --------- ## ## Platform. ## @@ -12,9 +12,9 @@ generated by GNU Autoconf 2.69. Invocation command line was hostname = manorhouse uname -m = x86_64 -uname -r = 4.20.5-200.fc29.x86_64 +uname -r = 4.20.6-200.fc29.x86_64 uname -s = Linux -uname -v = #1 SMP Mon Jan 28 19:29:17 UTC 2019 +uname -v = #1 SMP Thu Jan 31 15:50:43 UTC 2019 /usr/bin/uname -p = x86_64 /bin/uname -X = unknown @@ -124,6 +124,8 @@ configure:3213: $? = 0 configure:3225: result: yes configure:3245: checking whether make supports the include directive configure:3260: make -f confmf.GNU && cat confinc.out +make[1]: Entering directory '/home/morpheus/subu_land/subu' +make[1]: Leaving directory '/home/morpheus/subu_land/subu' this is the am__doit target configure:3263: $? = 0 configure:3282: result: yes (GNU style) @@ -133,28 +135,6 @@ configure:3546: checking that generated files are newer than configure configure:3552: result: done configure:3575: creating ./config.status -## ---------------------- ## -## 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 - -on manorhouse - -config.status:840: creating makefile -config.status:840: creating src/makefile -config.status:840: creating config.h -config.status:1069: executing depfiles commands -config.status:1146: cd src && sed -e '/# am--include-marker/d' makefile | make -f - am--depfiles -config.status:1151: $? = 0 - ## ---------------- ## ## Cache variables. ## ## ---------------- ## @@ -306,9 +286,40 @@ generated by GNU Autoconf 2.69. Invocation command line was CONFIG_HEADERS = CONFIG_LINKS = CONFIG_COMMANDS = - $ ./config.status config.h + $ ./config.status on manorhouse +config.status:840: creating makefile +config.status:840: creating src/makefile config.status:840: creating config.h config.status:1021: config.h is unchanged +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]: Nothing to be done for 'am--depfiles'. +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]: Nothing to be done for 'am--depfiles'. +make[1]: Leaving directory '/home/morpheus/subu_land/subu/src' +config.status:1151: $? = 0 diff --git a/src/.deps/useradd-0.Po b/src/.deps/useradd-0.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/src/.deps/useradd-0.Po @@ -0,0 +1 @@ +# dummy diff --git a/src/.deps/useradd-0.Tpo b/src/.deps/useradd-0.Tpo new file mode 100644 index 0000000..2e09570 --- /dev/null +++ b/src/.deps/useradd-0.Tpo @@ -0,0 +1,136 @@ +useradd-0.o: useradd-0.c /usr/include/stdc-predef.h \ + /usr/include/sys/types.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/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/bits/types/clock_t.h \ + /usr/include/bits/types/clockid_t.h /usr/include/bits/types/time_t.h \ + /usr/include/bits/types/timer_t.h \ + /usr/lib/gcc/x86_64-redhat-linux/8/include/stddef.h \ + /usr/include/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/bits/byteswap.h \ + /usr/include/bits/uintn-identity.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/types/sigset_t.h \ + /usr/include/bits/types/__sigset_t.h \ + /usr/include/bits/types/struct_timeval.h \ + /usr/include/bits/types/struct_timespec.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/thread-shared-types.h \ + /usr/include/bits/pthreadtypes-arch.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \ + /usr/include/bits/confname.h /usr/include/bits/getopt_posix.h \ + /usr/include/bits/getopt_core.h /usr/include/stdio.h \ + /usr/include/bits/libc-header-start.h \ + /usr/lib/gcc/x86_64-redhat-linux/8/include/stdarg.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 /usr/include/errno.h /usr/include/bits/errno.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/stdc-predef.h: + +/usr/include/sys/types.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/include/bits/types.h: + +/usr/include/bits/typesizes.h: + +/usr/include/bits/types/clock_t.h: + +/usr/include/bits/types/clockid_t.h: + +/usr/include/bits/types/time_t.h: + +/usr/include/bits/types/timer_t.h: + +/usr/lib/gcc/x86_64-redhat-linux/8/include/stddef.h: + +/usr/include/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/bits/endian.h: + +/usr/include/bits/byteswap.h: + +/usr/include/bits/uintn-identity.h: + +/usr/include/sys/select.h: + +/usr/include/bits/select.h: + +/usr/include/bits/types/sigset_t.h: + +/usr/include/bits/types/__sigset_t.h: + +/usr/include/bits/types/struct_timeval.h: + +/usr/include/bits/types/struct_timespec.h: + +/usr/include/bits/pthreadtypes.h: + +/usr/include/bits/thread-shared-types.h: + +/usr/include/bits/pthreadtypes-arch.h: + +/usr/include/unistd.h: + +/usr/include/bits/posix_opt.h: + +/usr/include/bits/environments.h: + +/usr/include/bits/confname.h: + +/usr/include/bits/getopt_posix.h: + +/usr/include/bits/getopt_core.h: + +/usr/include/stdio.h: + +/usr/include/bits/libc-header-start.h: + +/usr/lib/gcc/x86_64-redhat-linux/8/include/stdarg.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: + +/usr/include/errno.h: + +/usr/include/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: diff --git a/src/build-prep-notes.txt b/src/build-prep-notes.txt new file mode 100644 index 0000000..be8dcf8 --- /dev/null +++ b/src/build-prep-notes.txt @@ -0,0 +1,28 @@ +... turned into a notes file ... #!/bin/bash + +good doc: https://www.gnu.org/software/automake/manual/automake.html#Hello-World + +->create src/makefile.am +bin_PROGRAMS=subu-mk-0 +subu_mk_0_SOURCES=subu-mk-0.c + +->create makefile.am +SUBDIRS = src +dist_doc_DATA = README + +->create configure.ac +AC_INIT([mk-subu-0], [1.0], [bug-automake@gnu.org]) +AM_INIT_AUTOMAKE([-Wall -Werror foreign]) +AC_PROG_CC +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_FILES([ + makefile + src/makefile +]) +AC_OUTPUT + +autoreconf --install +./configure + +after changing makefile.am or configure.ac, it is enough to run make to update the build files + diff --git a/src/build-prep.sh b/src/build-prep.sh deleted file mode 100644 index be8dcf8..0000000 --- a/src/build-prep.sh +++ /dev/null @@ -1,28 +0,0 @@ -... turned into a notes file ... #!/bin/bash - -good doc: https://www.gnu.org/software/automake/manual/automake.html#Hello-World - -->create src/makefile.am -bin_PROGRAMS=subu-mk-0 -subu_mk_0_SOURCES=subu-mk-0.c - -->create makefile.am -SUBDIRS = src -dist_doc_DATA = README - -->create configure.ac -AC_INIT([mk-subu-0], [1.0], [bug-automake@gnu.org]) -AM_INIT_AUTOMAKE([-Wall -Werror foreign]) -AC_PROG_CC -AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_FILES([ - makefile - src/makefile -]) -AC_OUTPUT - -autoreconf --install -./configure - -after changing makefile.am or configure.ac, it is enough to run make to update the build files - diff --git a/src/local_common.h b/src/local_common.h new file mode 100644 index 0000000..5c17b7b --- /dev/null +++ b/src/local_common.h @@ -0,0 +1,7 @@ +#ifndef LOCAL_COMMON_H +#define LOCAL_COMMON_H + +typedef unsigned int uint; + + +#endif diff --git a/src/makefile b/src/makefile index 8bd7956..0f43241 100644 --- a/src/makefile +++ b/src/makefile @@ -99,7 +99,7 @@ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) -am_subu_mk_0_OBJECTS = subu-mk-0.$(OBJEXT) +am_subu_mk_0_OBJECTS = subu-mk-0.$(OBJEXT) useradd-0.$(OBJEXT) subu_mk_0_OBJECTS = $(am_subu_mk_0_OBJECTS) subu_mk_0_LDADD = $(LDADD) AM_V_P = $(am__v_P_$(V)) @@ -117,7 +117,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)/subu-mk-0.Po +am__depfiles_remade = ./$(DEPDIR)/subu-mk-0.Po \ + ./$(DEPDIR)/useradd-0.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -243,7 +244,10 @@ target_alias = top_build_prefix = ../ top_builddir = .. top_srcdir = .. -subu_mk_0_SOURCES = subu-mk-0.c +subu_mk_0_SOURCES = \ + subu-mk-0.c\ + useradd-0.c + all: all-am .SUFFIXES: @@ -331,6 +335,7 @@ distclean-compile: -rm -f *.tab.c include ./$(DEPDIR)/subu-mk-0.Po # am--include-marker +include ./$(DEPDIR)/useradd-0.Po # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @@ -480,6 +485,7 @@ clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/subu-mk-0.Po + -rm -f ./$(DEPDIR)/useradd-0.Po -rm -f makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -526,6 +532,7 @@ installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/subu-mk-0.Po + -rm -f ./$(DEPDIR)/useradd-0.Po -rm -f makefile maintainer-clean-am: distclean-am maintainer-clean-generic diff --git a/src/makefile.am b/src/makefile.am index 27143fc..3c4c5fd 100644 --- a/src/makefile.am +++ b/src/makefile.am @@ -1,3 +1,6 @@ bin_PROGRAMS=subu-mk-0 -subu_mk_0_SOURCES=subu-mk-0.c +subu_mk_0_SOURCES=\ + subu-mk-0.c\ + useradd-0.c + diff --git a/src/makefile.in b/src/makefile.in index 9c5f83d..79b7af5 100644 --- a/src/makefile.in +++ b/src/makefile.in @@ -99,7 +99,7 @@ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) -am_subu_mk_0_OBJECTS = subu-mk-0.$(OBJEXT) +am_subu_mk_0_OBJECTS = subu-mk-0.$(OBJEXT) useradd-0.$(OBJEXT) subu_mk_0_OBJECTS = $(am_subu_mk_0_OBJECTS) subu_mk_0_LDADD = $(LDADD) AM_V_P = $(am__v_P_@AM_V@) @@ -117,7 +117,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)/subu-mk-0.Po +am__depfiles_remade = ./$(DEPDIR)/subu-mk-0.Po \ + ./$(DEPDIR)/useradd-0.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -243,7 +244,10 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -subu_mk_0_SOURCES = subu-mk-0.c +subu_mk_0_SOURCES = \ + subu-mk-0.c\ + useradd-0.c + all: all-am .SUFFIXES: @@ -331,6 +335,7 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/subu-mk-0.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/useradd-0.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @@ -480,6 +485,7 @@ clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/subu-mk-0.Po + -rm -f ./$(DEPDIR)/useradd-0.Po -rm -f makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -526,6 +532,7 @@ installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/subu-mk-0.Po + -rm -f ./$(DEPDIR)/useradd-0.Po -rm -f makefile maintainer-clean-am: distclean-am maintainer-clean-generic diff --git a/src/subu-mk-0.c b/src/subu-mk-0.c index 396a52c..8649d10 100644 --- a/src/subu-mk-0.c +++ b/src/subu-mk-0.c @@ -1,134 +1,16 @@ /* - Makes a new subu user. - - Because this is a little utility program, we don't bother to free - buffers. The heap space will be released when the program exits. Actually we - can't free the buffers made by getpwid() even if wanted to. - - 1. We have to make the subu first so that we will have subu_uid and subu_gid - to work with. - - 2. Then we add user access via setfacl to masteru's home directory and to - subu_land, so that we have permissions to make the home directory. - - 3. Then as subu we create the home directory. .. I wonder where the system - gets the umask for this? Perhaps we should create the dir, and then change - the ownership instead? - - 4. Still as subu, we add facls to our directory to give masteru access. - - ... then finished, good part is that we never need to move back to root. - -setfacl -m u:subu:x masteru -setfacl -m u:subu:x masteru/subu_land -setfacl -m d:u:masteru:rwX,u:masteru:rwX subu + subu-mk-0 command */ -// without #define get warning: implicit declaration of function ‘seteuid’/‘setegid’ -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "config.h" - - -#define DEBUG -typedef unsigned int uint; - -#define ERR_ARG_CNT 1 -#define ERR_SETUID_ROOT 2 -#define ERR_BAD_MASTERU_HOME 3 -#define ERR_NOT_EXIST_MASTERU_HOME 4 -#define ERR_FAILED_MKDIR_SUBU 5 -#define ERR_FAILED_RESTORATION 6 +#include "subu-mk-0_fun.h" int main(int argc, char **argv, char **env){ - - //-------------------------------------------------------------------------------- - // help message + char *command = argv[0]; if( argc != 2 ){ - fprintf(stderr, "usage: %s subu", argv[0]); + fprintf(stderr, "usage: %s subu", command); return ERR_ARG_CNT; } - - //-------------------------------------------------------------------------------- - // we must be invoked from a user account and be running as root - uint uid = getuid(); - uint euid = geteuid(); - uint gid = getgid(); - uint egid = getegid(); - #ifdef DEBUG - printf("uid %u, gid %u, euid %u\n", uid, gid, euid); - #endif - if( uid == 0 || euid != 0 ){ - fprintf(stderr, "this program must be run setuid root from a user account\n"); - return ERR_SETUID_ROOT; - } - - //-------------------------------------------------------------------------------- - // who are these people anyway? - char *subu_name = argv[1]; - struct passwd *passwd_record_pt = getpwuid(uid); - char *masteru_name = passwd_record_pt->pw_name; - // verify that subu_name is legal! --> code goes here ... - - //-------------------------------------------------------------------------------- - // build the subu_land path - char *masteru_home_dir = passwd_record_pt->pw_dir; - size_t masteru_home_dir_len = strlen(masteru_home_dir); - if( masteru_home_dir_len == 0 || masteru_home_dir[0] == '(' ){ - fprintf(stderr,"strange, %s has no home directory\n", masteru_name); - return ERR_BAD_MASTERU_HOME; - } - char *subu_land_extension = "/subu_land/"; - size_t subu_land_extension_len = strlen(subu_land_extension); - size_t subu_name_len = strlen(subu_name); // we leave room in the buffer to latter add the subu_name - char *subu_land = (char *)malloc( masteru_home_dir_len + subu_land_extension_len + subu_name_len + 1 ); - strcpy(subu_land, masteru_home_dir); - strcpy(subu_land + masteru_home_dir_len, subu_land_extension); - #ifdef DEBUG - printf("The path to subu_land: %s\n", subu_land); - #endif - - //-------------------------------------------------------------------------------- - // Just because masteru_home_dir is referenced in /etc/passwd does not mean it exists. - // If it does, and the subu_land doesn't, then we make subu_land. - struct stat st; - if( stat(masteru_home_dir, &st) == -1) { - fprintf(stderr, "Strange, masteru home does not exist, %s.", masteru_home_dir); - return ERR_NOT_EXIST_MASTERU_HOME; - } - strcpy(subu_land + masteru_home_dir_len + subu_land_extension_len, subu_name); - #ifdef DEBUG - printf("A path to a subu: %s\n", subu_land); - #endif - - //-------------------------------------------------------------------------------- - // we need to have a subu_uid and subu_gid to continue from here - size_t subu_land_len = masteru_home_dir_len + subu_land_extension_len + subu_name_len; - - // change to subu space - if( seteuid(uid) == -1 || setegid(gid) == -1 ){ // we are root so this should never happen - fprintf(stderr,"Strangely, root could not seteuid/setegid to %s\n", masteru_name); - return ERR_FAILED_MKDIR_SUBU; - } - if( stat(subu_land, &st) == -1) { // then make the directory - if( mkdir(subu_land, 0700) == -1 || stat(subu_land, &st) == -1 ){ - fprintf(stderr,"Failed to make subu directory %s\n", subu_land); - return ERR_FAILED_MKDIR_SUBU; - } - } - //change back to set the acls - if( seteuid(euid) == -1 || setegid(egid) == -1 ){ - fprintf(stderr,"Could not restore privledges, having to bail.\n"); - return ERR_FAILED_RESTORATION; - } - return 0; + uid_gid ug = subu-mk-0(argv[1]); + return ug.error; } diff --git a/src/subu-mk-0.def.c b/src/subu-mk-0.def.c new file mode 100644 index 0000000..0adc76f --- /dev/null +++ b/src/subu-mk-0.def.c @@ -0,0 +1,145 @@ +/* + Makes a new subu user. + + According to the man page, we are not alloed to free the buffers made by getpwid(). + + 1. We have to make the subu first so that we will have subu_uid and subu_gid + to work with. + + 2. Then we add user access via setfacl to masteru's home directory and to + subu_land, so that we have permissions to make the home directory. + + 3. Then as subu we create the home directory. .. I wonder where the system + gets the umask for this? Perhaps we should create the dir, and then change + the ownership instead? + + 4. Still as subu, we add facls to our directory to give masteru access. + + ... then finished, good part is that we never need to move back to root. + +setfacl -m u:subu:x masteru +setfacl -m u:subu:x masteru/subu_land +setfacl -m d:u:masteru:rwX,u:masteru:rwX subu + +*/ +// without #define get warning: implicit declaration of function ‘seteuid’/‘setegid’ +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "config.h" +#include "subu_mk_0_fun.h" + +#define DEBUG +typedef unsigned int uint; + +#define ERR_ARG_CNT 1 +#define ERR_SETUID_ROOT 2 +#define ERR_BAD_MASTERU_HOME 3 +#define ERR_NOT_EXIST_MASTERU_HOME 4 +#define ERR_FAILED_MKDIR_SUBU 5 +#define ERR_FAILED_RESTORATION 6 + +uid_gid subu_mk_0(char *subu_name){ + + //-------------------------------------------------------------------------------- + // help message + char *command = argv[0]; + if( argc != 2 ){ + fprintf(stderr, "usage: %s subu", command); + return ERR_ARG_CNT; + } + + //-------------------------------------------------------------------------------- + // we must be invoked from a user account and be running as root + uint uid = getuid(); + uint euid = geteuid(); + uint gid = getgid(); + uint egid = getegid(); + #ifdef DEBUG + printf("uid %u, gid %u, euid %u\n", uid, gid, euid); + #endif + if( uid == 0 || euid != 0 ){ + fprintf(stderr, "this program must be run setuid root from a user account\n"); + return ERR_SETUID_ROOT; + } + + //-------------------------------------------------------------------------------- + // who are these people anyway? + char *subu_name = argv[1]; + struct passwd *passwd_record_pt = getpwuid(uid); + char *masteru_name = passwd_record_pt->pw_name; + // verify that subu_name is legal! --> code goes here ... + + //-------------------------------------------------------------------------------- + // build the subu_land path + char *masteru_home_dir = passwd_record_pt->pw_dir; + size_t masteru_home_dir_len = strlen(masteru_home_dir); + if( masteru_home_dir_len == 0 || masteru_home_dir[0] == '(' ){ + fprintf(stderr,"strange, %s has no home directory\n", masteru_name); + return ERR_BAD_MASTERU_HOME; + } + char *subu_land_extension = "/subu_land/"; + size_t subu_land_extension_len = strlen(subu_land_extension); + size_t subu_name_len = strlen(subu_name); // we leave room in the buffer to latter add the subu_name + char *subu_land = (char *)malloc( masteru_home_dir_len + subu_land_extension_len + subu_name_len + 1 ); + strcpy(subu_land, masteru_home_dir); + strcpy(subu_land + masteru_home_dir_len, subu_land_extension); + #ifdef DEBUG + printf("The path to subu_land: %s\n", subu_land); + #endif + + //-------------------------------------------------------------------------------- + // Just because masteru_home_dir is referenced in /etc/passwd does not mean it exists. + // If it does, and the subu_land doesn't, then we make subu_land. + struct stat st; + if( stat(masteru_home_dir, &st) == -1) { + fprintf(stderr, "Strange, masteru home does not exist, %s.", masteru_home_dir); + return ERR_NOT_EXIST_MASTERU_HOME; + } + + //-------------------------------------------------------------------------------- + // the name for the subu home directory, which is subu_land/subu_name + size_t subu_land_len = masteru_home_dir_len + subu_land_extension_len + subu_name_len; + strcpy (subu_land + subu_land_len, subu_name); // we had left room in the subu_land buffer for subu_name + char *subu_home_path = subu_land; // the buffer now holds the subu_home_path, so we call it as such + #ifdef DEBUG + printf("subu home: %s\n", subu_home_path); + #endif + + //-------------------------------------------------------------------------------- + // we now make the subu + char *useradd_argv[4]; + useradd_argv[0] = command; + useradd_argv[1] = "-d"; + useradd_argv[2] = subu_home_path; + useradd_argv[3] = (char *) NULL; + char *useradd_envp[1]; + useradd_envp[0] (char *) NULL; + useradd_0(subu_name, useradd_argv, envp); + + // change to subu space + if( seteuid(uid) == -1 || setegid(gid) == -1 ){ // we are root so this should never happen + fprintf(stderr,"Strangely, root could not seteuid/setegid to %s\n", masteru_name); + return ERR_FAILED_MKDIR_SUBU; + } + if( stat(subu_land, &st) == -1) { // then make the directory + if( mkdir(subu_land, 0700) == -1 || stat(subu_land, &st) == -1 ){ + fprintf(stderr,"Failed to make subu directory %s\n", subu_land); + return ERR_FAILED_MKDIR_SUBU; + } + } + //change back to set the acls + if( seteuid(euid) == -1 || setegid(egid) == -1 ){ + fprintf(stderr,"Could not restore privledges, having to bail.\n"); + return ERR_FAILED_RESTORATION; + } + return 0; +} diff --git a/src/subu_mk_0_def.h b/src/subu_mk_0_def.h new file mode 100644 index 0000000..1749c43 --- /dev/null +++ b/src/subu_mk_0_def.h @@ -0,0 +1,7 @@ +#ifndef SUBU_MK_0_H +#define SUBU_MK_0_H + +#include "useradd-fun.h" +uid_gid subu_mk_0(char *subu_name); + +#endif diff --git a/src/useradd_fun.c b/src/useradd_fun.c new file mode 100644 index 0000000..8fe6d13 --- /dev/null +++ b/src/useradd_fun.c @@ -0,0 +1,40 @@ +/* +There is no C library interface to useradd(8), but if there were, these functions +would be found there instead. I'm also wondering about the wisdom of using +useradd(8) from shadow. Wondering if the locks are in place for multiple users hitting it +simultaneously via different methods, and if it handles signals cleanly. + +We pass argv[1:..] and envp through to useradd. We return the uid of the newly +created user, or the negative value of the return code from useradd(8) + +*/ + +#include +#include +#include +#include +#include + +// better to change this to vargs for the option list +// this currently works because I know there is only one option +int useradd_0(char *user, char **argv, char **envp){ + char *subu_name; + if( argv && argv[0] && argv[1] ){ + + } + pid_t pid = fork(void); + if( pid == -1 ) return 1; + if( pid == 0 ){ // we are the child + char *command = "/usr/bin/useradd"; + argv[0] = command; // we can do this because we made the argv in the caller + int err = execvpe( command, argv, envp); + fprintf(stderr, "subu execvpe call to /usr/bin/useradd issued error %d, but it is too difficult to tell the parent process about this.", errno); + } else { + int wstatus; + wait(1, &wstatus, 0); + if(wstatus != 0) return -abs(wstatus); + // useradd did not tell us the uid of the newly created user, so now we have go get it. + struct passwd *getpwname( + } + +} diff --git a/src/useradd_fun.h b/src/useradd_fun.h new file mode 100644 index 0000000..a2d6e2f --- /dev/null +++ b/src/useradd_fun.h @@ -0,0 +1,14 @@ + +#ifndef USERADD_H +#define USERADD_H +#include local_common.h + +struct uid_gid{ + uint error; + pid_t uid; + pid_t gid; +}; + +uit_gid useradd_0(char *user, char **argv, char **envp); + +#endif