subu-0 execs compile again
authorThomas Walker Lynch <thomas.lynch@reasoningtechnology.com>
Tue, 2 Apr 2019 19:12:28 +0000 (21:12 +0200)
committerThomas Walker Lynch <thomas.lynch@reasoningtechnology.com>
Tue, 2 Apr 2019 19:12:28 +0000 (21:12 +0200)
33 files changed:
module/da/lib/libda.a
module/da/test/lib/libtest.a
module/da/test/makefile
module/debug/lib/libdebug.a
module/dispatch/lib/libdispatch.a
module/share/include/da.h
module/share/include/subu.h [new file with mode: 0644]
module/subu-0/exec/subu-bind [new file with mode: 0755]
module/subu-0/exec/subu-bind-all [new file with mode: 0755]
module/subu-0/exec/subu-mk-0 [new file with mode: 0755]
module/subu-0/exec/subu-rm-0 [new file with mode: 0755]
module/subu-0/exec/subudb-init [new file with mode: 0755]
module/subu-0/exec/subudb-number [new file with mode: 0755]
module/subu-0/exec/subudb-rel-get [new file with mode: 0755]
module/subu-0/exec/subudb-rel-put [new file with mode: 0755]
module/subu-0/exec/subudb-rel-rm [new file with mode: 0755]
module/subu-0/exec/subudb-subus [new file with mode: 0755]
module/subu-0/include/subu.h
module/subu-0/lib/libsubu-0.a
module/subu-0/makefile
module/subu-0/makefile-flags
module/subu-0/trc/subu-bind-all.trc.c
module/subu-0/trc/subu-bind.trc.c
module/subu-0/trc/subu-mk-0.trc.c
module/subu-0/trc/subu-rm-0.trc.c
module/subu-0/trc/subudb-init.trc.c
module/subu-0/trc/subudb-number.trc.c
module/subu-0/trc/subudb-rel-get.trc.c
module/subu-0/trc/subudb-rel-put.trc.c
module/subu-0/trc/subudb-rel-rm.trc.c
module/subu-0/trc/subudb-subus.trc.c
module/subu-0/trc/subudb.trc.c
module/tranche/lib/libtranche.a

index 28db3cb..a535373 100644 (file)
Binary files a/module/da/lib/libda.a and b/module/da/lib/libda.a differ
index 49e4695..7081270 100644 (file)
Binary files a/module/da/test/lib/libtest.a and b/module/da/test/lib/libtest.a differ
index 9df325d..ab92883 100644 (file)
@@ -22,6 +22,11 @@ lib:
 exec:
        $(MAKE) $@
 
+.PHONY: share
+share:
+       @echo "module/da/test nothing to share"
+
+
 %::
        $(MAKE) $@
 
index df2a6dd..05415b9 100644 (file)
Binary files a/module/debug/lib/libdebug.a and b/module/debug/lib/libdebug.a differ
index 70d2fff..54ca624 100644 (file)
Binary files a/module/dispatch/lib/libdispatch.a and b/module/dispatch/lib/libdispatch.a differ
index 8195c4a..52ffb4e 100644 (file)
@@ -4,7 +4,7 @@
 #include <stdbool.h>
 #include <stdio.h>
 
-typedef struct Da{
+typedef struct{
   char *base;
   char *end; // one byte/one element off the end of the array
   size_t size; // size >= (end - base) + 1;
diff --git a/module/share/include/subu.h b/module/share/include/subu.h
new file mode 100644 (file)
index 0000000..683ddb3
--- /dev/null
@@ -0,0 +1,62 @@
+  typedef unsigned int uint;
+  /*
+    Fedora 29's sss_cache is checking the inherited uid instead of the effective
+    uid, so setuid root scripts will fail when calling sss_cache.
+
+    Fedora 29's 'useradd' calls sss_cache, and useradd is called by our setuid root 
+    program subu-mk-0.
+  */
+  #define BUG_SSS_CACHE_RUID 1
+  // extern char *DB_File;
+  extern char DB_File[];
+  extern uint Subuhome_Perms;
+  extern uint First_Max_Subunumber;
+  extern char Subuland_Extension[];
+  /*
+  The db file is maintained in SQLite
+
+  Because linux user names are limited length, subu user names are of a compact
+  form: _s<number>.  A separate table translates the numbers into the subu names.
+
+  Each of these returns SQLITE_OK upon success
+  */
+  #include <sqlite3.h>
+  int db_begin(sqlite3 *db);
+  int db_commit(sqlite3 *db);
+  int db_rollback(sqlite3 *db);
+  int subudb_schema(sqlite3 *db);
+  int subudb_number_get(sqlite3 *db, int *n);
+  int subudb_number_set(sqlite3 *db, int n);
+  int subudb_Masteru_Subu_put(sqlite3 *db, char *masteru_name, char *subuname, char *subu_username);
+  int subudb_Masteru_Subu_get_subu_username(sqlite3 *db, char *masteru_name, char *subuname, char **subu_username);
+  typedef struct{
+    char *subuname; // the name that masteru chose for his or her subu
+    char *subu_username;  // the adduser name we gave it, typically of the s<number>
+  } subudb_subu_element;
+  int subudb_Masteru_Subu_get_subus(sqlite3 *db, char *masteru_name, Da *subus);
+  int subudb_Masteru_Subu_rm(sqlite3 *db, char *masteru_name, char *subuname, char *subu_username);
+  #include <stdbool.h>
+  #include <errno.h>
+  #include <sqlite3.h>
+  char *useradd_mess(int err);
+  char *userdel_mess(int err);
+  #define SUBU_ERR_ARG_CNT 1
+  #define SUBU_ERR_SETUID_ROOT 2
+  #define SUBU_ERR_MALLOC 3
+  #define SUBU_ERR_MKDIR_SUBUHOME 4
+  #define SUBU_ERR_RMDIR_SUBUHOME 5
+  #define SUBU_ERR_SUBUNAME_MALFORMED 6
+  #define SUBU_ERR_HOMELESS 7
+  #define SUBU_ERR_DB_FILE 8
+  #define SUBU_ERR_SUBUHOME_EXISTS 9
+  #define SUBU_ERR_BUG_SSS 10
+  #define SUBU_ERR_FAILED_USERADD 11
+  #define SUBU_ERR_FAILED_USERDEL 12
+  #define SUBU_ERR_SUBU_NOT_FOUND 13
+  #define SUBU_ERR_N 14
+  #define SUBU_ERR_BIND 15
+  void subu_err(char *fname, int err, char *mess);
+  int subu_mk_0(char **mess, sqlite3 *db, char *subuname);
+  int subu_rm_0(char **mess, sqlite3 *db, char *subuname);
+  int subu_bind(char **mess, char *masteru_name, char *subu_username, char *subuhome);
+  int subu_bind_all(char **mess, sqlite3 *db);
diff --git a/module/subu-0/exec/subu-bind b/module/subu-0/exec/subu-bind
new file mode 100755 (executable)
index 0000000..3c27383
Binary files /dev/null and b/module/subu-0/exec/subu-bind differ
diff --git a/module/subu-0/exec/subu-bind-all b/module/subu-0/exec/subu-bind-all
new file mode 100755 (executable)
index 0000000..d6bf08c
Binary files /dev/null and b/module/subu-0/exec/subu-bind-all differ
diff --git a/module/subu-0/exec/subu-mk-0 b/module/subu-0/exec/subu-mk-0
new file mode 100755 (executable)
index 0000000..4fdf004
Binary files /dev/null and b/module/subu-0/exec/subu-mk-0 differ
diff --git a/module/subu-0/exec/subu-rm-0 b/module/subu-0/exec/subu-rm-0
new file mode 100755 (executable)
index 0000000..2d6c42e
Binary files /dev/null and b/module/subu-0/exec/subu-rm-0 differ
diff --git a/module/subu-0/exec/subudb-init b/module/subu-0/exec/subudb-init
new file mode 100755 (executable)
index 0000000..b389cea
Binary files /dev/null and b/module/subu-0/exec/subudb-init differ
diff --git a/module/subu-0/exec/subudb-number b/module/subu-0/exec/subudb-number
new file mode 100755 (executable)
index 0000000..a0ba2c9
Binary files /dev/null and b/module/subu-0/exec/subudb-number differ
diff --git a/module/subu-0/exec/subudb-rel-get b/module/subu-0/exec/subudb-rel-get
new file mode 100755 (executable)
index 0000000..8d5bf37
Binary files /dev/null and b/module/subu-0/exec/subudb-rel-get differ
diff --git a/module/subu-0/exec/subudb-rel-put b/module/subu-0/exec/subudb-rel-put
new file mode 100755 (executable)
index 0000000..76667e2
Binary files /dev/null and b/module/subu-0/exec/subudb-rel-put differ
diff --git a/module/subu-0/exec/subudb-rel-rm b/module/subu-0/exec/subudb-rel-rm
new file mode 100755 (executable)
index 0000000..cd64ce9
Binary files /dev/null and b/module/subu-0/exec/subudb-rel-rm differ
diff --git a/module/subu-0/exec/subudb-subus b/module/subu-0/exec/subudb-subus
new file mode 100755 (executable)
index 0000000..2abcd16
Binary files /dev/null and b/module/subu-0/exec/subudb-subus differ
index 683ddb3..5a82782 100644 (file)
@@ -20,6 +20,7 @@
 
   Each of these returns SQLITE_OK upon success
   */
+  #include <da.h>
   #include <sqlite3.h>
   int db_begin(sqlite3 *db);
   int db_commit(sqlite3 *db);
index e678762..63f4e5b 100644 (file)
Binary files a/module/subu-0/lib/libsubu-0.a and b/module/subu-0/lib/libsubu-0.a differ
index dacec61..c12df9c 100644 (file)
@@ -32,6 +32,10 @@ dep:
        fi
        $(MAKE) $@
 
+.PHONY: exec
+exec:
+       $(MAKE) $@
+
 .PHONY: lib
 lib:
        cp $(SRCDIR)/common.lib.h $(INCDIR)/subu.h
index f373601..ae748ac 100644 (file)
@@ -25,7 +25,4 @@ ECHO= echo
 # compiler and flags
 C=gcc
 CFLAGS=-std=gnu11 -fPIC -I$(SRCDIR) -I$(INCDIR) -I$(SHAREDIR)/include -ggdb -Werror -DDEBUG -DDEBUGDB 
-LINKFLAGS=-L$(LIBDIR) -L$(SHAREDIR)/lib/ -l$(MODULE) -lda -ltranche -ldispatch
-
-
-
+LINKFLAGS=-L$(LIBDIR) -L$(SHAREDIR)/lib/ -l$(MODULE) -lda -ldispatch -ldebug -lsqlite3
index 7674927..66dfe19 100644 (file)
@@ -6,6 +6,8 @@ uses unmount to undo this
 */
 #include <stdio.h>
 #include <stdlib.h>
+#include "common.lib.h"
+#include "subu.lib.h"
 
 int main(int argc, char **argv){
   if( argc != 1){
index 0510d55..93ce926 100644 (file)
@@ -4,8 +4,11 @@ mount a subu user directory into master's subuland
 uses unmount to undo this
 
 */
+#include <subu.lib.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include "common.lib.h"
+#include "subu.lib.h"
 
 int main(int argc, char **argv){
 
index f0a7b5a..0ae869b 100644 (file)
@@ -5,6 +5,9 @@
 */
 #include <stdio.h>
 #include <stdlib.h>
+#include <sqlite3.h>
+#include "common.lib.h"
+#include "subu.lib.h"
 
 int main(int argc, char **argv){
   char *command = argv[0];
index e49e611..f7fa21b 100644 (file)
@@ -5,6 +5,8 @@
 */
 #include <stdio.h>
 #include <stdlib.h>
+#include "common.lib.h"
+#include "subu.lib.h"
 
 int main(int argc, char **argv){
   char *command = argv[0];
index 794644d..69bc2a7 100644 (file)
@@ -4,6 +4,9 @@ This command initializes the db file.
 
 */
 #include <stdio.h>
+#include "common.lib.h"
+#include "subudb.lib.h"
+#include "subu.lib.h"
 
 int main(){
   sqlite3 *db;
index 183aec0..7844b47 100644 (file)
@@ -6,6 +6,9 @@ Set or get a new maximum subu number. Currently doesn't do the setting part.
 #include <stdio.h>
 #include <stdlib.h>
 #include <limits.h>
+#include "common.lib.h"
+#include "subudb.lib.h"
+#include "subu.lib.h"
 
 int main(int argc, char **argv){
 
index e64331a..b1f87e3 100644 (file)
@@ -6,6 +6,9 @@ for testing subudb_Masteru_Subu_get_subu_username
 */
 #include <stdio.h>
 #include <stdlib.h>
+#include "common.lib.h"
+#include "subudb.lib.h"
+#include "subu.lib.h"
 
 int main(int argc, char **argv){
 
index 5352700..86d8beb 100644 (file)
@@ -5,6 +5,9 @@ puts a relation in the masteru/subu table
 */
 #include <stdio.h>
 #include <stdlib.h>
+#include "common.lib.h"
+#include "subudb.lib.h"
+#include "subu.lib.h"
 
 int main(int argc, char **argv){
 
index 6008c70..88bd70a 100644 (file)
@@ -5,6 +5,9 @@ puts a relation in the masteru/subu table
 */
 #include <stdio.h>
 #include <stdlib.h>
+#include "common.lib.h"
+#include "subudb.lib.h"
+#include "subu.lib.h"
 
 int main(int argc, char **argv){
 
index 4871967..500f641 100644 (file)
@@ -6,6 +6,9 @@ Set or get a new maximum subu number. Currently doesn't do the setting part.
 #include <stdio.h>
 #include <stdlib.h>
 #include <limits.h>
+#include "common.lib.h"
+#include "subudb.lib.h"
+#include "subu.lib.h"
 
 int main(int argc, char **argv){
 
@@ -24,14 +27,16 @@ int main(int argc, char **argv){
     return SUBU_ERR_DB_FILE;
   }
 
-  subudb_subu_element *sa;
-  subudb_subu_element *sa_end;
-  rc = subudb_Masteru_Subu_get_subus(db, masteru_name, &sa, &sa_end);
+  Da subu_arr;
+  Da *subu_arrp = &subu_arr;
+  rc = subudb_Masteru_Subu_get_subus(db, masteru_name, subu_arrp);
   if( rc == SQLITE_OK ){
-    subudb_subu_element *pt = sa;
-    while( pt != sa_end ){
-      printf("%s %s\n", pt->subuname, pt->subu_username);
-    pt++;
+    char *pt = subu_arrp->base;
+    subudb_subu_element *pt1;
+    while( pt < subu_arrp->end ){
+      pt1 = (subudb_subu_element *)pt;
+      printf("%s %s\n", pt1->subuname, pt1->subu_username);
+    pt += subu_arrp->element_size;
     }
     rc = sqlite3_close(db);
     if( rc != SQLITE_OK ){
index 27d5639..c6fb603 100644 (file)
@@ -8,16 +8,17 @@
 
   Each of these returns SQLITE_OK upon success
   */
+  #include <da.h>
   #include <sqlite3.h>
 #tranche-end
 
-#include <da.h>
-#include "common.lib.h"
-#include "subudb.lib.h"
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdbool.h>
+#include <da.h>
+#include "common.lib.h"
+#include "subudb.lib.h"
 
 //--------------------------------------------------------------------------------
 // sqlite transactions don't nest.  There is a way to use save points, but still
index 407c21b..ceba37a 100644 (file)
Binary files a/module/tranche/lib/libtranche.a and b/module/tranche/lib/libtranche.a differ