rda-python-miscs 3.0.6__tar.gz → 3.0.7__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 (63) hide show
  1. {rda_python_miscs-3.0.6/src/rda_python_miscs.egg-info → rda_python_miscs-3.0.7}/PKG-INFO +6 -1
  2. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/README.md +5 -0
  3. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/pyproject.toml +1 -1
  4. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexdrop.py +46 -2
  5. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexdrop.usg +3 -1
  6. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7/src/rda_python_miscs.egg-info}/PKG-INFO +6 -1
  7. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/LICENSE +0 -0
  8. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/MANIFEST.in +0 -0
  9. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/setup.cfg +0 -0
  10. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/__init__.py +0 -0
  11. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/bash_qsub.py +0 -0
  12. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/bashqsub.py +0 -0
  13. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/bashqsub.usg +0 -0
  14. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/decsdata_restore.py +0 -0
  15. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/decsdata_restore.usg +0 -0
  16. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/decsdata_storage.py +0 -0
  17. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/decsdata_storage.usg +0 -0
  18. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdex_ls.py +0 -0
  19. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexcp.py +0 -0
  20. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexcp.usg +0 -0
  21. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexdrop_standalone.py +0 -0
  22. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexkill.py +0 -0
  23. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexkill.usg +0 -0
  24. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexls.py +0 -0
  25. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexls.usg +0 -0
  26. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexls_standalone.py +0 -0
  27. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexmod.py +0 -0
  28. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexmod.usg +0 -0
  29. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexown.py +0 -0
  30. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexown.usg +0 -0
  31. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexps.py +0 -0
  32. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexps.usg +0 -0
  33. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexsub.py +0 -0
  34. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexsub.usg +0 -0
  35. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexzip.py +0 -0
  36. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/gdexzip.usg +0 -0
  37. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/pg_docs.py +0 -0
  38. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/pg_rst.py +0 -0
  39. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/pg_rst.usg +0 -0
  40. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/pg_wget.py +0 -0
  41. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/pgwget.py +0 -0
  42. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/pgwget.usg +0 -0
  43. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/rda_cp.py +0 -0
  44. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/rda_kill.py +0 -0
  45. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/rda_mod.py +0 -0
  46. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/rda_own.py +0 -0
  47. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/rda_ps.py +0 -0
  48. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/rda_sub.py +0 -0
  49. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/rda_zip.py +0 -0
  50. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/rdals.py +0 -0
  51. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/rdals.usg +0 -0
  52. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/rst_templates/appendix.rst.temp +0 -0
  53. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/rst_templates/index.rst.temp +0 -0
  54. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/rst_templates/section.rst.temp +0 -0
  55. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/tcsh_qsub.py +0 -0
  56. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/tcshqsub.py +0 -0
  57. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs/tcshqsub.usg +0 -0
  58. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs.egg-info/SOURCES.txt +0 -0
  59. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs.egg-info/dependency_links.txt +0 -0
  60. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs.egg-info/entry_points.txt +0 -0
  61. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs.egg-info/requires.txt +0 -0
  62. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/src/rda_python_miscs.egg-info/top_level.txt +0 -0
  63. {rda_python_miscs-3.0.6 → rda_python_miscs-3.0.7}/tests/test_miscs.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rda_python_miscs
3
- Version: 3.0.6
3
+ Version: 3.0.7
4
4
  Summary: RDA Python package to hold RDA miscellaneous utility programs
5
5
  Author-email: Zaihua Ji <zji@ucar.edu>
6
6
  Project-URL: Homepage, https://github.com/NCAR/rda-python-miscs
@@ -172,6 +172,11 @@ deliberately narrow alternative to `gdexcp`: the destination is always
172
172
  directory is rejected, and every source must be readable by the calling user
173
173
  rather than only by `gdexdata`.
174
174
 
175
+ Everything dropped, including sub-directories created for `-t`, is also set to the
176
+ GDEX group `PGLOG['GDEXGRP']`. The setuid wrapper switches only the user to
177
+ `gdexdata`, not the group, so without that step a dropped file would stay in the
178
+ calling user's group unless the directory it landed in carried the setgid bit.
179
+
175
180
  Who may drop into which dataset is read from the access list
176
181
  `/glade/u/home/gdexdata/config/gdexdrop.conf`. It must be owned by `gdexdata`
177
182
  and must not be writable by group or others, otherwise `gdexdrop` refuses to
@@ -155,6 +155,11 @@ deliberately narrow alternative to `gdexcp`: the destination is always
155
155
  directory is rejected, and every source must be readable by the calling user
156
156
  rather than only by `gdexdata`.
157
157
 
158
+ Everything dropped, including sub-directories created for `-t`, is also set to the
159
+ GDEX group `PGLOG['GDEXGRP']`. The setuid wrapper switches only the user to
160
+ `gdexdata`, not the group, so without that step a dropped file would stay in the
161
+ calling user's group unless the directory it landed in carried the setgid bit.
162
+
158
163
  Who may drop into which dataset is read from the access list
159
164
  `/glade/u/home/gdexdata/config/gdexdrop.conf`. It must be owned by `gdexdata`
160
165
  and must not be writable by group or others, otherwise `gdexdrop` refuses to
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "rda_python_miscs"
9
- version = "3.0.6"
9
+ version = "3.0.7"
10
10
  authors = [
11
11
  { name="Zaihua Ji", email="zji@ucar.edu" },
12
12
  ]
@@ -32,7 +32,8 @@ class GdexDrop(PgFile):
32
32
  by -t, and is verified to stay inside that dataset directory. The caller must
33
33
  be granted the dataset in the gdexdrop access list, and must be able to read
34
34
  every source path as themselves; both checks exist because the copy itself
35
- runs with the privileges of 'gdexdata'.
35
+ runs with the privileges of 'gdexdata'. Everything dropped is then set to the
36
+ GDEX group PGLOG['GDEXGRP'], which the copy does not land in on its own.
36
37
  """
37
38
 
38
39
  def __init__(self):
@@ -164,8 +165,11 @@ class GdexDrop(PgFile):
164
165
  """
165
166
  self.DINFO['target'] = self.resolve_target()
166
167
  self.validate_caller()
168
+ if not self.PGLOG['GDEXGID']:
169
+ self.pglog(self.PGLOG['GDEXGRP'] + ": Unknown Group to own the dropped files", self.LGEREX)
167
170
  self.PGLOG['FILEMODE'] = self.DROP['F']
168
171
  self.PGLOG['EXECMODE'] = self.DROP['D']
172
+ self.make_target_directory()
169
173
  for file in self.DROP['f']:
170
174
  self.DINFO['tcnt'] += self.drop_one(file)
171
175
  if self.DINFO['tcnt'] > 0:
@@ -245,6 +249,44 @@ class GdexDrop(PgFile):
245
249
  if not ('all' in dsids or self.DROP['ds'] in dsids):
246
250
  self.pglog("{}: NOT granted Dataset {} in {}".format(logname, self.DROP['ds'], DROPCONF), self.LGEREX)
247
251
 
252
+ # create the target directory, and set the group of each directory created
253
+ def make_target_directory(self):
254
+ """Create the sub-directories named by -t that do not exist yet.
255
+
256
+ They are created here rather than on the fly by local_copy_local() so that
257
+ set_drop_group() can be called on each one; a directory left in the calling
258
+ user's group could not be written into by the rest of the DECS group later.
259
+ """
260
+ newdirs = []
261
+ dir = self.DINFO['target']
262
+ while not op.isdir(dir):
263
+ newdirs.insert(0, dir)
264
+ dir = op.dirname(dir)
265
+ if not newdirs: return
266
+ self.make_local_directory(self.DINFO['target'], self.LGWNEX)
267
+ for dir in newdirs: self.set_drop_group(dir)
268
+
269
+ # set the group of a dropped path, and of everything under it for a directory
270
+ def set_drop_group(self, path):
271
+ """Set the group of path, and of all of its contents for a directory.
272
+
273
+ The copy runs with an effective user of 'gdexdata' but with the EFFECTIVE
274
+ GROUP of the caller, so a dropped file lands in the caller's group unless
275
+ the directory it lands in happens to carry the setgid bit. Symbolic links
276
+ are skipped, since os.chown() follows them out of the dataset directory.
277
+
278
+ Args:
279
+ path (str): Absolute path of a dropped file or directory.
280
+ """
281
+ if op.islink(path): return
282
+ self.change_local_group(path, None, None, None, self.LOGWRN)
283
+ if not op.isdir(path): return
284
+ for root, dirs, files in os.walk(path):
285
+ for name in dirs + files:
286
+ subpath = op.join(root, name)
287
+ if op.islink(subpath): continue
288
+ self.change_local_group(subpath, None, None, None, self.LOGWRN)
289
+
248
290
  # copy one source path into the target directory
249
291
  def drop_one(self, file):
250
292
  """Copy one source file or directory into the target directory.
@@ -269,7 +311,9 @@ class GdexDrop(PgFile):
269
311
  if tinfo and tinfo['data_size'] == finfo['data_size']:
270
312
  self.pglog(tofile + ": Target exists with same size, skip copying", self.LOGWRN)
271
313
  return 0
272
- return (1 if self.local_copy_local(tofile, path, self.LGWNEX) else 0)
314
+ if not self.local_copy_local(tofile, path, self.LGWNEX): return 0
315
+ self.set_drop_group(tofile)
316
+ return 1
273
317
 
274
318
  # main function to execute this script
275
319
  def main():
@@ -40,7 +40,9 @@
40
40
 
41
41
  Every source path must be readable by the calling user, not merely by
42
42
  'gdexdata'; a path the caller cannot read themselves is refused. Copied files
43
- and directories are owned by 'gdexdata'.
43
+ and directories are owned by 'gdexdata' and belong to the GDEX group, as do any
44
+ sub-directories created for -t; without that they would stay in the calling
45
+ user's group, since only the user is switched to 'gdexdata', not the group.
44
46
 
45
47
  Access List
46
48
  -----------
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rda_python_miscs
3
- Version: 3.0.6
3
+ Version: 3.0.7
4
4
  Summary: RDA Python package to hold RDA miscellaneous utility programs
5
5
  Author-email: Zaihua Ji <zji@ucar.edu>
6
6
  Project-URL: Homepage, https://github.com/NCAR/rda-python-miscs
@@ -172,6 +172,11 @@ deliberately narrow alternative to `gdexcp`: the destination is always
172
172
  directory is rejected, and every source must be readable by the calling user
173
173
  rather than only by `gdexdata`.
174
174
 
175
+ Everything dropped, including sub-directories created for `-t`, is also set to the
176
+ GDEX group `PGLOG['GDEXGRP']`. The setuid wrapper switches only the user to
177
+ `gdexdata`, not the group, so without that step a dropped file would stay in the
178
+ calling user's group unless the directory it landed in carried the setgid bit.
179
+
175
180
  Who may drop into which dataset is read from the access list
176
181
  `/glade/u/home/gdexdata/config/gdexdrop.conf`. It must be owned by `gdexdata`
177
182
  and must not be writable by group or others, otherwise `gdexdrop` refuses to