Browse Source

Automatically generate util/devtable

K. Lange 4 years ago
parent
commit
a0528a6c7c
4 changed files with 46 additions and 25 deletions
  1. 22 20
      .gitignore
  2. 4 1
      Makefile
  3. 0 4
      util/devtable
  4. 20 0
      util/update-devtable.py

+ 22 - 20
.gitignore

@@ -2,25 +2,27 @@
 *.a
 *.o
 *.iso
-.make/*
-base/bin/*
-cdrom/kernel
-cdrom/netinit
-cdrom/mod/*
-cdrom/ramdisk.img
-cdrom/boot.sys
-cdrom/fat.img
-fatbase/kernel
-fatbase/netinit
-fatbase/mod/*
-fatbase/ramdisk.img
-fatbase/efi/boot/bootia32.efi
 *.efi
-util/tarballs
-util/build
-util/local
 .gdb_history
-kernel/symbols.S
-base/usr/python
-base/usr/bin/*
-base/usr/lib/*
+
+/.make/*
+/base/bin/*
+/cdrom/kernel
+/cdrom/netinit
+/cdrom/mod/*
+/cdrom/ramdisk.img
+/cdrom/boot.sys
+/cdrom/fat.img
+/fatbase/kernel
+/fatbase/netinit
+/fatbase/mod/*
+/fatbase/ramdisk.img
+/fatbase/efi/boot/bootia32.efi
+/util/tarballs
+/util/build
+/util/local
+/util/devtable
+/kernel/symbols.S
+/base/usr/python
+/base/usr/bin/*
+/base/usr/lib/*

+ 4 - 1
Makefile

@@ -168,7 +168,10 @@ endif
 
 # Ramdisk
 
-fatbase/ramdisk.img: ${APPS_X} ${LIBS_X} base/lib/ld.so base/lib/libm.so $(shell find base) Makefile | dirs
+util/devtable: $(shell find base) util/update-devtable.py
+	util/update-devtable.py
+
+fatbase/ramdisk.img: ${APPS_X} ${LIBS_X} base/lib/ld.so base/lib/libm.so $(shell find base) Makefile util/devtable | dirs
 	genext2fs -B 4096 -d base -D util/devtable -U -b `util/calc-size.sh` -N 2048 $@
 
 # CD image

+ 0 - 4
util/devtable

@@ -1,4 +0,0 @@
-/home/local             d 775  1000 1000 - - - - -
-/home/local/hello       f 664  1000 1000 - - - - -
-/etc/master.passwd      f 600  0    0    - - - - -
-/bin/sudo               f 4555 0    0    - - - - -

+ 20 - 0
util/update-devtable.py

@@ -0,0 +1,20 @@
+#!/usr/bin/env python3
+import os
+import glob
+from pathlib import Path
+
+with open('util/devtable','w') as devtable:
+    devtable.write('/bin/sudo f 4555 0 0 - - - - -\n') # sudo always needs setuid
+    devtable.write('/etc/master.passwd f 600 0 0 - - - - -\n') # /etc/master.passwd should be restricted
+
+    # Now add user home directories
+    for user_details in [('local',1000)]:
+        user, uid = user_details
+        for path in glob.glob(f'./base/home/{user}/**',recursive=True):
+            p = Path(path)
+            path_mod = path.replace('./base','')
+            path_type = 'd' if p.is_dir() else 'f'
+            st = os.stat(path)
+            mode = '{:o}'.format(st.st_mode & 0o7777)
+            devtable.write(f'{path_mod} {path_type} {mode} {uid} {uid} - - - - -\n')
+