rda-python-setuid 1.0.8__tar.gz → 1.0.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (19) hide show
  1. {rda_python_setuid-1.0.8/src/rda_python_setuid.egg-info → rda_python_setuid-1.0.9}/PKG-INFO +4 -4
  2. {rda_python_setuid-1.0.8 → rda_python_setuid-1.0.9}/README.md +3 -3
  3. {rda_python_setuid-1.0.8 → rda_python_setuid-1.0.9}/pyproject.toml +1 -1
  4. {rda_python_setuid-1.0.8 → rda_python_setuid-1.0.9}/src/rda_python_setuid/install.py +10 -12
  5. {rda_python_setuid-1.0.8 → rda_python_setuid-1.0.9}/src/rda_python_setuid/install.usg +7 -6
  6. {rda_python_setuid-1.0.8 → rda_python_setuid-1.0.9}/src/rda_python_setuid/pgstart.py +1 -1
  7. {rda_python_setuid-1.0.8 → rda_python_setuid-1.0.9/src/rda_python_setuid.egg-info}/PKG-INFO +4 -4
  8. {rda_python_setuid-1.0.8 → rda_python_setuid-1.0.9}/LICENSE +0 -0
  9. {rda_python_setuid-1.0.8 → rda_python_setuid-1.0.9}/MANIFEST.in +0 -0
  10. {rda_python_setuid-1.0.8 → rda_python_setuid-1.0.9}/setup.cfg +0 -0
  11. {rda_python_setuid-1.0.8 → rda_python_setuid-1.0.9}/src/rda_python_setuid/__init__.py +0 -0
  12. {rda_python_setuid-1.0.8 → rda_python_setuid-1.0.9}/src/rda_python_setuid/pywrapper.c +0 -0
  13. {rda_python_setuid-1.0.8 → rda_python_setuid-1.0.9}/src/rda_python_setuid/pywrapper.py +0 -0
  14. {rda_python_setuid-1.0.8 → rda_python_setuid-1.0.9}/src/rda_python_setuid.egg-info/SOURCES.txt +0 -0
  15. {rda_python_setuid-1.0.8 → rda_python_setuid-1.0.9}/src/rda_python_setuid.egg-info/dependency_links.txt +0 -0
  16. {rda_python_setuid-1.0.8 → rda_python_setuid-1.0.9}/src/rda_python_setuid.egg-info/entry_points.txt +0 -0
  17. {rda_python_setuid-1.0.8 → rda_python_setuid-1.0.9}/src/rda_python_setuid.egg-info/requires.txt +0 -0
  18. {rda_python_setuid-1.0.8 → rda_python_setuid-1.0.9}/src/rda_python_setuid.egg-info/top_level.txt +0 -0
  19. {rda_python_setuid-1.0.8 → rda_python_setuid-1.0.9}/tests/test_setuid.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rda_python_setuid
3
- Version: 1.0.8
3
+ Version: 1.0.9
4
4
  Summary: RDA Python Package to setuid for program executions as an effective or common user
5
5
  Author-email: Zaihua Ji <zji@ucar.edu>
6
6
  Project-URL: Homepage, https://github.com/NCAR/rda-python-setuid
@@ -74,8 +74,9 @@ prefix:
74
74
  ```
75
75
 
76
76
  `pip install` then places `setuid_dsarch` in the environment's `bin/` directory
77
- automatically. `pywrapper-install -l/--link` locks it down to `chmod 700` so users
78
- cannot bypass the setuid wrapper by running it directly.
77
+ automatically. `pywrapper-install -l/--link` creates the symlink
78
+ `dsarch -> pywrapper`; running `dsarch` goes through the setuid wrapper, which
79
+ execs `setuid_dsarch` as CommonUser.
79
80
 
80
81
  ## Environment setup
81
82
 
@@ -138,7 +139,6 @@ pywrapper-install -l|--link dsarch -s|--simple
138
139
  user runs: dsarch [args]
139
140
  | (symlink -> pywrapper, setuid bit -> EUID=gdexdata)
140
141
  pywrapper.c: execv(bin/setuid_dsarch, args)
141
- | (chmod 700, only gdexdata can exec directly)
142
142
  setuid_dsarch: calls dsarch:main() as gdexdata
143
143
  ```
144
144
 
@@ -58,8 +58,9 @@ prefix:
58
58
  ```
59
59
 
60
60
  `pip install` then places `setuid_dsarch` in the environment's `bin/` directory
61
- automatically. `pywrapper-install -l/--link` locks it down to `chmod 700` so users
62
- cannot bypass the setuid wrapper by running it directly.
61
+ automatically. `pywrapper-install -l/--link` creates the symlink
62
+ `dsarch -> pywrapper`; running `dsarch` goes through the setuid wrapper, which
63
+ execs `setuid_dsarch` as CommonUser.
63
64
 
64
65
  ## Environment setup
65
66
 
@@ -122,7 +123,6 @@ pywrapper-install -l|--link dsarch -s|--simple
122
123
  user runs: dsarch [args]
123
124
  | (symlink -> pywrapper, setuid bit -> EUID=gdexdata)
124
125
  pywrapper.c: execv(bin/setuid_dsarch, args)
125
- | (chmod 700, only gdexdata can exec directly)
126
126
  setuid_dsarch: calls dsarch:main() as gdexdata
127
127
  ```
128
128
 
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "rda_python_setuid"
9
- version = "1.0.8"
9
+ version = "1.0.9"
10
10
  authors = [
11
11
  { name="Zaihua Ji", email="zji@ucar.edu" },
12
12
  ]
@@ -31,8 +31,9 @@
31
31
  # [project.scripts]
32
32
  # "setuid_dsarch" = "rda_python_dsarch.dsarch:main"
33
33
  # pip install places setuid_dsarch in the bin dir automatically.
34
- # pywrapper-install --link dsarch will chown setuid_dsarch to CommonUser and
35
- # chmod 700, so users cannot run it directly and must go through the setuid wrapper.
34
+ # pywrapper-install --link dsarch creates the symlink dsarch -> pywrapper, so
35
+ # users invoking dsarch go through the setuid wrapper which execs setuid_dsarch
36
+ # as CommonUser.
36
37
  # pywrapper-install --link dsarch --simple creates dsarch -> setuid_dsarch directly,
37
38
  # skipping setuid; the program runs as the current user.
38
39
  #
@@ -125,19 +126,13 @@ def main():
125
126
  os.symlink(script, target)
126
127
  print("Created: {} -> setuid_{}".format(target, args.link))
127
128
  else:
128
- # Mode 1: symlink PROGRAM -> pywrapper, then lock down setuid_PROGRAM
129
- # so users cannot bypass the setuid wrapper by running it directly.
129
+ # Mode 1: symlink PROGRAM -> pywrapper. setuid_PROGRAM is left with its
130
+ # default ownership/permissions so it can be loaded and executed normally.
130
131
  if os.path.lexists(target):
131
132
  print("Already exists: {}".format(target))
132
133
  else:
133
134
  os.symlink(pywrapper, target)
134
135
  print("Created: {} -> pywrapper".format(target))
135
- # chown and chmod 700: only CommonUser can execute setuid_PROGRAM directly.
136
- # pywrapper (running as CommonUser via setuid) can still execv it, but any
137
- # direct invocation by other users will get "permission denied".
138
- run(['sudo', '-u', args.user, 'chown', args.user, script])
139
- run(['sudo', '-u', args.user, 'chmod', '700', script])
140
- print("Locked: {} (chmod 700, owned by {})".format(script, args.user))
141
136
 
142
137
  elif args.pgstart:
143
138
  # Mode 2: copy pywrapper to pgstart_USER with setuid owned by USER
@@ -145,8 +140,11 @@ def main():
145
140
  print("Error: {} not found. Run pywrapper-install --user COMMONUSER first.".format(pywrapper))
146
141
  sys.exit(1)
147
142
  target = os.path.join(bindir, 'pgstart_{}'.format(args.user))
148
- run(['sudo', '-u', args.user, 'cp', pywrapper, target])
149
- run(['sudo', '-u', args.user, 'chmod', '4750', target])
143
+ import pwd
144
+ curuser = pwd.getpwuid(os.getuid()).pw_name
145
+ sudo_prefix = [] if curuser == args.user else ['sudo', '-u', args.user]
146
+ run(sudo_prefix + ['cp', pywrapper, target])
147
+ run(sudo_prefix + ['chmod', '4750', target])
150
148
  print("Installed: {} (setuid, owned by {})".format(target, args.user))
151
149
 
152
150
  elif args.compile:
@@ -35,10 +35,11 @@
35
35
  setuid wrapper. Cannot be combined with -c/--compile or -l/--link.
36
36
 
37
37
  - Option -l or --link PROGRAM
38
- Mode 1: create a symlink PROGRAM -> pywrapper in the bin/ directory, then
39
- lock down setuid_PROGRAM (chmod 700, owned by USER) so users cannot bypass
40
- the setuid wrapper by running setuid_PROGRAM directly. Cannot be combined
41
- with -c/--compile or -p/--pgstart.
38
+ Mode 1: create a symlink PROGRAM -> pywrapper in the bin/ directory so
39
+ that running PROGRAM invokes the setuid wrapper, which then execs
40
+ setuid_PROGRAM as CommonUser. setuid_PROGRAM keeps its default
41
+ ownership and permissions. Cannot be combined with -c/--compile or
42
+ -p/--pgstart.
42
43
 
43
44
  - Option -s or --simple (use with -l/--link)
44
45
  Simple install: create a symlink PROGRAM -> setuid_PROGRAM directly,
@@ -66,8 +67,8 @@
66
67
  "setuid_dsarch" = "rda_python_dsarch.dsarch:main"
67
68
 
68
69
  pip install then places setuid_dsarch in the bin/ directory automatically.
69
- Running pywrapper-install --link will lock it down (chmod 700) so that only
70
- pywrapper (running as CommonUser via its setuid bit) can execv it.
70
+ Running pywrapper-install --link creates the symlink dsarch -> pywrapper;
71
+ pywrapper (running as CommonUser via its setuid bit) execs setuid_dsarch.
71
72
 
72
73
  Environment Setup:
73
74
 
@@ -49,7 +49,7 @@ def main():
49
49
  euid = pglog.PGLOG['EUID']
50
50
  ruser = pwd.getpwuid(ruid).pw_name
51
51
  euser = pwd.getpwuid(euid).pw_name
52
- if ruser == euser or ruser == pglog.PGLOG['GDEXUSER']: permit = True
52
+ if ruser == euser or ruser == pglog.PGLOG['GDEXUSER'] or euser == pglog.PGLOG['GDEXUSER']: permit = True
53
53
  pglog.set_suid(euid)
54
54
 
55
55
  while argv:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rda_python_setuid
3
- Version: 1.0.8
3
+ Version: 1.0.9
4
4
  Summary: RDA Python Package to setuid for program executions as an effective or common user
5
5
  Author-email: Zaihua Ji <zji@ucar.edu>
6
6
  Project-URL: Homepage, https://github.com/NCAR/rda-python-setuid
@@ -74,8 +74,9 @@ prefix:
74
74
  ```
75
75
 
76
76
  `pip install` then places `setuid_dsarch` in the environment's `bin/` directory
77
- automatically. `pywrapper-install -l/--link` locks it down to `chmod 700` so users
78
- cannot bypass the setuid wrapper by running it directly.
77
+ automatically. `pywrapper-install -l/--link` creates the symlink
78
+ `dsarch -> pywrapper`; running `dsarch` goes through the setuid wrapper, which
79
+ execs `setuid_dsarch` as CommonUser.
79
80
 
80
81
  ## Environment setup
81
82
 
@@ -138,7 +139,6 @@ pywrapper-install -l|--link dsarch -s|--simple
138
139
  user runs: dsarch [args]
139
140
  | (symlink -> pywrapper, setuid bit -> EUID=gdexdata)
140
141
  pywrapper.c: execv(bin/setuid_dsarch, args)
141
- | (chmod 700, only gdexdata can exec directly)
142
142
  setuid_dsarch: calls dsarch:main() as gdexdata
143
143
  ```
144
144