rda-python-setuid 1.0.1__tar.gz → 1.0.3__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 (17) hide show
  1. {rda_python_setuid-1.0.1 → rda_python_setuid-1.0.3}/PKG-INFO +3 -2
  2. {rda_python_setuid-1.0.1 → rda_python_setuid-1.0.3}/pyproject.toml +1 -1
  3. {rda_python_setuid-1.0.1 → rda_python_setuid-1.0.3}/src/rda_python_setuid/pgstart.py +19 -3
  4. {rda_python_setuid-1.0.1 → rda_python_setuid-1.0.3}/src/rda_python_setuid/pywrapper.c +11 -13
  5. {rda_python_setuid-1.0.1 → rda_python_setuid-1.0.3}/src/rda_python_setuid.egg-info/PKG-INFO +3 -2
  6. {rda_python_setuid-1.0.1 → rda_python_setuid-1.0.3}/LICENSE +0 -0
  7. {rda_python_setuid-1.0.1 → rda_python_setuid-1.0.3}/MANIFEST.in +0 -0
  8. {rda_python_setuid-1.0.1 → rda_python_setuid-1.0.3}/README.md +0 -0
  9. {rda_python_setuid-1.0.1 → rda_python_setuid-1.0.3}/setup.cfg +0 -0
  10. {rda_python_setuid-1.0.1 → rda_python_setuid-1.0.3}/src/rda_python_setuid/__init__.py +0 -0
  11. {rda_python_setuid-1.0.1 → rda_python_setuid-1.0.3}/src/rda_python_setuid/pywrapper.py +0 -0
  12. {rda_python_setuid-1.0.1 → rda_python_setuid-1.0.3}/src/rda_python_setuid.egg-info/SOURCES.txt +0 -0
  13. {rda_python_setuid-1.0.1 → rda_python_setuid-1.0.3}/src/rda_python_setuid.egg-info/dependency_links.txt +0 -0
  14. {rda_python_setuid-1.0.1 → rda_python_setuid-1.0.3}/src/rda_python_setuid.egg-info/entry_points.txt +0 -0
  15. {rda_python_setuid-1.0.1 → rda_python_setuid-1.0.3}/src/rda_python_setuid.egg-info/requires.txt +0 -0
  16. {rda_python_setuid-1.0.1 → rda_python_setuid-1.0.3}/src/rda_python_setuid.egg-info/top_level.txt +0 -0
  17. {rda_python_setuid-1.0.1 → rda_python_setuid-1.0.3}/tests/test_setuid.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: rda_python_setuid
3
- Version: 1.0.1
3
+ Version: 1.0.3
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
@@ -12,5 +12,6 @@ Requires-Python: >=3.7
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: rda_python_common
15
+ Dynamic: license-file
15
16
 
16
17
  RDA python package, including a C code wrapper, to execute commandline applications via setuid for effective and common user names.
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "rda_python_setuid"
9
- version = "1.0.1"
9
+ version = "1.0.3"
10
10
  authors = [
11
11
  { name="Zaihua Ji", email="zji@ucar.edu" },
12
12
  ]
@@ -35,10 +35,16 @@ def main():
35
35
  PgLOG.set_suid(PgLOG.PGLOG['EUID'])
36
36
  if PgLOG.PGLOG['CURUID'] != PgLOG.PGLOG['RDAUSER'] and PgLOG.PGLOG['CURUID'] != "zji": permit = 0
37
37
 
38
- if argv:
38
+ while argv:
39
39
  ms = re.match(r'^-(\w+)$', argv[0])
40
- if ms:
41
- opt = ms.group(1)
40
+ if not ms: break
41
+ argv.pop(0)
42
+ opt = ms.group(1)
43
+ if opt == "bg":
44
+ bckgrd = " &"
45
+ elif opt == "cwd":
46
+ if argv: workdir = argv.pop(0)
47
+ elif opt != "fg":
42
48
  display_message(opt)
43
49
 
44
50
  if not (permit and argv):
@@ -52,7 +58,17 @@ def main():
52
58
  if not permit:
53
59
  print("* You must be '{}' to execute a command as user '{}'.".format(PgLOG.PGLOG['RDAUSER'], euser))
54
60
  print("********************************************************************")
61
+ sys.exit(0)
55
62
 
63
+ cmd = PgLOG.argv_to_string(argv)
64
+
65
+ msg = "{}-{}{}-{}".format(PgLOG.PGLOG['HOSTNAME'], aname, PgLOG.current_datetime(), PgLOG.PGLOG['CURUID'])
66
+ if workdir:
67
+ msg += "-" + workdir
68
+ os.chdir(workdir)
69
+
70
+ PgLOG.pglog("{}: {}".format(msg, cmd), PgLOG.MSGLOG)
71
+ os.system(cmd + bckgrd)
56
72
  sys.exit(0)
57
73
 
58
74
  #
@@ -42,16 +42,11 @@
42
42
  int is_executable(const char *filename) {
43
43
  struct stat sb;
44
44
 
45
- if(stat(filename, &sb) == 0) {
46
- if(sb.st_mode & S_IXUSR) {
47
- return 1;
48
- } else {
49
- printf("%s: not executable\n", prog);
50
- }
45
+ if(stat(filename, &sb) == 0 && sb.st_mode & S_IXUSR) {
46
+ return 1;
51
47
  } else {
52
- printf("%s: not exists\n", prog);
48
+ return 0;
53
49
  }
54
- return 0;
55
50
  }
56
51
 
57
52
  /* main program */
@@ -59,13 +54,15 @@ int main(int argc, char *argv[]) {
59
54
  char *name;
60
55
  char cname[80], prog[255];
61
56
  char file[] = __FILE__;
57
+ char *fpath = dirname(file);
62
58
  char pgstart[] = "pgstart";
59
+ char **apntr = argv;
63
60
 
64
61
  name = strrchr(argv[0], '/');
65
62
  strcpy(cname, (name == NULL ? argv[0] : ++name));
66
63
 
67
64
  if(strstr(cname, pgstart) == cname) {
68
- if(argc == 1 or argv[1][0] == '-') {
65
+ if(argc == 1 || argv[1][0] == '-') {
69
66
  strcpy(cname, pgstart);
70
67
  } else {
71
68
  argv += 1;
@@ -73,9 +70,10 @@ int main(int argc, char *argv[]) {
73
70
  strcpy(cname, (name == NULL ? argv[0] : ++name));
74
71
  }
75
72
  }
76
- sprintf(prog, "%s/%s.py", dirname(file), cname);
77
-
78
- if(is_executable(prog) {
79
- execv(prog, argv); /* call Python script */
73
+ sprintf(prog, "%s/%s.py", fpath, cname);
74
+ if(is_executable(prog) == 0) {
75
+ sprintf(prog, "%s/pgstart.py", fpath);
76
+ argv = apntr;
80
77
  }
78
+ execv(prog, argv); /* call Python script */
81
79
  }
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: rda_python_setuid
3
- Version: 1.0.1
3
+ Version: 1.0.3
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
@@ -12,5 +12,6 @@ Requires-Python: >=3.7
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: rda_python_common
15
+ Dynamic: license-file
15
16
 
16
17
  RDA python package, including a C code wrapper, to execute commandline applications via setuid for effective and common user names.