atomicshop 2.5.14__py3-none-any.whl → 2.5.15__py3-none-any.whl
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.
Potentially problematic release.
This version of atomicshop might be problematic. Click here for more details.
- atomicshop/__init__.py +1 -1
- atomicshop/permissions.py +35 -0
- {atomicshop-2.5.14.dist-info → atomicshop-2.5.15.dist-info}/METADATA +1 -1
- {atomicshop-2.5.14.dist-info → atomicshop-2.5.15.dist-info}/RECORD +7 -7
- {atomicshop-2.5.14.dist-info → atomicshop-2.5.15.dist-info}/LICENSE.txt +0 -0
- {atomicshop-2.5.14.dist-info → atomicshop-2.5.15.dist-info}/WHEEL +0 -0
- {atomicshop-2.5.14.dist-info → atomicshop-2.5.15.dist-info}/top_level.txt +0 -0
atomicshop/__init__.py
CHANGED
atomicshop/permissions.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import ctypes
|
|
3
|
+
import contextlib
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
def is_admin() -> bool:
|
|
@@ -20,3 +21,37 @@ def is_admin() -> bool:
|
|
|
20
21
|
result = False
|
|
21
22
|
|
|
22
23
|
return result
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@contextlib.contextmanager
|
|
27
|
+
def temporary_regular_permissions():
|
|
28
|
+
"""
|
|
29
|
+
This function is used to temporarily change the effective user and group ID to the original user's.
|
|
30
|
+
This is used to run commands with the original user's permissions.
|
|
31
|
+
If you executed a script with 'sudo' and wanted certain action to execute as regular user and not root.
|
|
32
|
+
|
|
33
|
+
Example:
|
|
34
|
+
with temporary_regular_permissions():
|
|
35
|
+
# Do something with regular permissions.
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
:return:
|
|
39
|
+
"""
|
|
40
|
+
# Save the current effective user and group ID
|
|
41
|
+
original_euid, original_egid = os.geteuid(), os.getegid()
|
|
42
|
+
|
|
43
|
+
try:
|
|
44
|
+
# Get the original user's UID and GID
|
|
45
|
+
orig_uid = int(os.environ.get('SUDO_UID', os.getuid()))
|
|
46
|
+
orig_gid = int(os.environ.get('SUDO_GID', os.getgid()))
|
|
47
|
+
|
|
48
|
+
# Set the effective user and group ID to the original user's
|
|
49
|
+
os.setegid(orig_gid)
|
|
50
|
+
os.seteuid(orig_uid)
|
|
51
|
+
|
|
52
|
+
# Provide the context to do something with these permissions
|
|
53
|
+
yield
|
|
54
|
+
finally:
|
|
55
|
+
# Revert to the original effective user and group ID
|
|
56
|
+
os.seteuid(original_euid)
|
|
57
|
+
os.setegid(original_egid)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
atomicshop/__init__.py,sha256=
|
|
1
|
+
atomicshop/__init__.py,sha256=VHWnXlEZ9dAZpc3c2DWsrkxZnCkZZZQ7x9bDbQCK-1A,123
|
|
2
2
|
atomicshop/_basics_temp.py,sha256=6cu2dd6r2dLrd1BRNcVDKTHlsHs_26Gpw8QS6v32lQ0,3699
|
|
3
3
|
atomicshop/appointment_management.py,sha256=N3wVGJgrqJfsj_lqiRfaL3FxMEe57by5Stzanh189mk,7263
|
|
4
4
|
atomicshop/archiver.py,sha256=QuDKx6bJEM29u-7r2tsizXEEGJmPuv0Xm91JQOpg__8,7152
|
|
@@ -20,7 +20,7 @@ atomicshop/inspect_wrapper.py,sha256=sGRVQhrJovNygHTydqJj0hxES-aB2Eg9KbIk3G31apw
|
|
|
20
20
|
atomicshop/ip_addresses.py,sha256=GBG9YXEqHItmGEgKwqatx28CbWislFI2ZI2xVHGIqO4,759
|
|
21
21
|
atomicshop/keyboard_press.py,sha256=1W5kRtOB75fulVx-uF2yarBhW0_IzdI1k73AnvXstk0,452
|
|
22
22
|
atomicshop/pbtkmultifile_argparse.py,sha256=aEk8nhvoQVu-xyfZosK3ma17CwIgOjzO1erXXdjwtS4,4574
|
|
23
|
-
atomicshop/permissions.py,sha256=
|
|
23
|
+
atomicshop/permissions.py,sha256=tfODaD-81zv0PrpAW-9MMULHaGe2r9TRnkP7MPhN-mQ,1735
|
|
24
24
|
atomicshop/print_api.py,sha256=3n1CoiXvDcDGg00n5gEmQYInHryIhWbcpNjVobO1Gao,11468
|
|
25
25
|
atomicshop/process.py,sha256=i_25PrSqSBbTcstCi_8rWVXAEYco81l6b9x1l_egTOY,14193
|
|
26
26
|
atomicshop/process_name_cmd.py,sha256=TNAK6kQZm5JKWzEW6QLqVHEG98ZLNDQiSS4YwDk8V8c,3830
|
|
@@ -192,8 +192,8 @@ atomicshop/wrappers/socketw/socket_server_tester.py,sha256=VfNthyBvgI5tL9v3Qprh4
|
|
|
192
192
|
atomicshop/wrappers/socketw/socket_wrapper.py,sha256=aXBwlEIJhFT0-c4i8iNlFx2It9VpCEpsv--5Oqcpxao,11624
|
|
193
193
|
atomicshop/wrappers/socketw/ssl_base.py,sha256=k4V3gwkbq10MvOH4btU4onLX2GNOsSfUAdcHmL1rpVE,2274
|
|
194
194
|
atomicshop/wrappers/socketw/statistics_csv.py,sha256=t3dtDEfN47CfYVi0CW6Kc2QHTEeZVyYhc57IYYh5nmA,826
|
|
195
|
-
atomicshop-2.5.
|
|
196
|
-
atomicshop-2.5.
|
|
197
|
-
atomicshop-2.5.
|
|
198
|
-
atomicshop-2.5.
|
|
199
|
-
atomicshop-2.5.
|
|
195
|
+
atomicshop-2.5.15.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
|
|
196
|
+
atomicshop-2.5.15.dist-info/METADATA,sha256=AyVvRv1KbiiTq3Nt404Vt_r12RbbmEYuCOs5oOZ_HaM,10268
|
|
197
|
+
atomicshop-2.5.15.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
|
|
198
|
+
atomicshop-2.5.15.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
|
|
199
|
+
atomicshop-2.5.15.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|