-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed pathing for OSes (GPG, TMP, Home, etc. for Windows/Linux/Unix) #104
Conversation
* Dropping cached passphrased * Dropping interactive mode * Dropping gpg1 support
… path.py as a linpius util.
Changes made has been tested on Mac, Linux, and Windows. pius.spec needs to have cross compatibility for other OSes, or multi stage depending on the platform run a different set of instructions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting effort into the Windows stuff... definitely not something I have done. :) Appreciated.
Fixed capitals for non constants. and made variable names more clear for others.
added default linux tempdir path as constant
Decided on Constant being in the path file.
Decided against having tempdir path being in this file.
updated function names and added import for some constants, also provided a check to see if the platform is windows or linux, if windows then do a normal which search, if linux then use the path constant with normal path separators to see if it exists with the other bin files.
fixed function names to reflect the changes in the paths file
due to calling path in constants.py LINUX_TEMPDIR and BIN_PATHS need to be in this file as it will cause a import loop between this file and constants.py
Fixed variable name not being complete, and changed hard code of existing hard code constant.
fixed function names to reflect previous changes
fixed oversight. %APPDATA% places user in their roaming folder, no need to have it as part of path join as it is already in the home variable.
Removed unused import
I see I hadn't been very clear on some of my comments before - my apologies. Please don't hesitate to ask for further clarification on anything else. Thanks again for improving the experience for non-Linux users! |
removed old comment from EOF. removed elif statement from incorrect spot.
added back a previously deleted function. added 2 checks to pius home on linux/unix systems.
Remember that windows __does not__ use the same structure tree as Linux there is no such thing as /usr in windows. If you want it removed then you can freely do so give me a few minutes and I will add you as a maintainer/contributor on my git repo
Sent from my T-Mobile 4G LTE Device
-------- Original message --------From: Phil Dibowitz <[email protected]> Date: 9/23/18 00:38 (GMT-05:00) To: jaymzh/pius <[email protected]> Cc: Alexander Featherson <[email protected]>, Author <[email protected]> Subject: Re: [jaymzh/pius] Fixed pathing for OSes (GPG, TMP, Home, etc. for Windows/Linux/Unix) (#104)
@jaymzh commented on this pull request.
In
libpius/path.py:
@@ -0,0 +1,124 @@
+'''A set of path functions and variables for the PIUS suite.'''
+from __future__ import print_function
+
+import os
+import sys
+import stat
+from os.path import abspath
+import fnmatch
+
+LINUX_TEMPDIR = '/tmp/'
+BIN_PATHS = '/usr/bin;/usr/sbin/;/bin;/sbin;/usr/local/bin;/usr/local/sbin'
No distribution installs software into /usr/local - that's now how FSB works. /usr/local is where user-compiled software goes, which is not where we'd expect security-sensitive software like GPG to be on a Linux machine. We should
not look in /usr/local by default on windows unless to user asks us to. Remember the user can do so with a config file by adding
gpg-path=/usr/local/bin/gpg to their .piusrc. That's
why we have a config file for anyone with a non-standard configuration.
—
You are receiving this because you authored the thread.
Reply to this email directly,
view it on GitHub, or
mute the thread.
|
Seperated MacOS and Linux binary paths Mac check joins mac and linux binary paths
Latest commit should fix the last of your major concerns, push come to shove i could make it more narrowed down to just Cellar (Homebrew) and MacGPG2 (GPG Tools suite) |
Additional fixes to issues that have not been caught previously.
Change ; to :
Fixed ordering of files to be checked for.
New function to find current piusrc
fixed some typos in nested if statement. added new function to get piusrc and check if the home for pius is a directory or a file.
Resolved the issue about order of pius home checks in turn also fixing a hard coded path that should be checked if it is a dir or not. |
gpg = which('gpg2') | ||
elif sys.platform == "darwin": | ||
#joining all possible paths for location of mac binaries | ||
BIN_PATHS = MAC_BIN_PATHS+":"+LINUX_BIN_PATHS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing )
here...
if os.path.exists(os.path.join(usrhome, '.pius')) and os.access(os.path.join(usrhome,'.pius'), mode) and os.path.isdir(os.path.join(usrhome,'.pius')): | ||
piushome = os.path.join(usrhome,'.pius') | ||
elif os.path.exists(os.path.join(usrhome, '.piusrc')) and os.access(os.path.join(usrhome,'.piusrc'), mode) and os.path.isdir(os.path.join(usrhome,'.piusrc')): | ||
piushome = os.path.join(usrhome,'.piusrc') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.piusrc was never a dir, it was always a file.
#fall back if above is not applicable | ||
else: | ||
piushome = os.path.join(usrhome, '.pius') | ||
return piushome |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method returns a dir in the if, a file in the first elif, a dir in the second, a dir in the third. and a file in the else
|
||
def get_piusrc(path): | ||
if sys.platform == "win32": | ||
if os.path.islink(path) and not os.path.isfile(path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be and os.path.isdir(path)
?
if sys.platform == "win32": | ||
if os.path.islink(path) and not os.path.isfile(path): | ||
return os.path.join(path, 'piusrc') | ||
elif os.path.isfile(path) and not os.path.islink(path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it's not a file and not a link, then... it's a ... file?
|
||
def get_tmpdir(dir): | ||
if sys.platform == "win32": | ||
tempdir = os.environ.get('TEMP') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if that's not defined?
if os.environ.get('USER') == "root": | ||
tempdir = '/private/tmp/' | ||
else: | ||
tempdir = os.environ.get('TMPDIR') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
Updated single commit to better track/organize for pulling.
libpius/path.py handles pathing of the local machine and determines what to use or do based on the host OS.
set_tmpdir() is hard coded for Mac (Darwin) and linux as $TMPDIR doesn't respond correctly or is not an env variable in varying versions.
(Note: MacOS uses mktemp which is not able to be accessed by anyone* except the user, some versions of linux use $TMP/$TEMP/$TMPDIR/$TEMPDIR or just doesn't exist at all)
*includes root