'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' )
);
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
--- /dev/null
+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:
/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:
/usr/lib/gcc/x86_64-redhat-linux/8/include/stdbool.h:
+dbprintf.aux.h:
+
dispatch.lib.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:
/usr/lib/gcc/x86_64-redhat-linux/8/include/stdbool.h:
+dbprintf.aux.h:
+
dispatch.lib.h:
dispatch_useradd.lib.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:
/usr/lib/gcc/x86_64-redhat-linux/8/include/stdbool.h:
+dbprintf.aux.h:
+
dispatch_useradd.lib.h:
subu-mk-0.lib.h:
--- /dev/null
+
+#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;
+}
--- /dev/null
+#ifndef DBPRINTF_AUX_H
+#define DBPRINTF_AUX_H
+
+int dbprintf(const char *format, ...);
+
+#endif
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 ){
#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
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))
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
top_builddir = ..
top_srcdir = ..
subu_mk_0_SOURCES = \
+ dbprintf.aux.c\
subu-mk-0.cli.c\
subu-mk-0.lib.c\
dispatch.lib.c\
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
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
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
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\
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@)
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
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\
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
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
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
#!/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
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");
}
//--------------------------------------------------------------------------------
- // 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);
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] == '(' ){
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);
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 ){
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
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;
}
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;
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");
}
//--------------------------------------------------------------------------------
- // 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);
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;
}
}
+ #ifdef DEBUG
+ dbprintf("finished subu-mk-0(%s) without error\n", subuname);
+ #endif
free(subuland);
free(subuhome);
return 0;
--- /dev/null
+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§