Permalink
Browse files

m + ensure that change stuff always has proper permissions

  • Loading branch information...
1 parent 21eb735 commit e600c3cb471bb23792a959e885f504cd48757bb5 @maandree maandree committed Oct 8, 2012
Showing with 16 additions and 3 deletions.
  1. +14 −1 ponysay.py
  2. +2 −2 setup.py
View
@@ -804,18 +804,21 @@ def __kms(self, pony):
## Get and in necessary make cache directory
cachedir = '/var/cache/ponysay'
+ shared = True
if not os.path.isdir(cachedir):
cachedir = HOME + '/.cache/ponysay'
+ shared = False
if not os.path.isdir(cachedir):
os.makedirs(cachedir)
+ _cachedir = '\'' + cachedir.replace('\'', '\'\\\'\'') + '\''
## KMS support version control, clean everything if not matching
newversion = False
if not os.path.isfile(cachedir + '/.version'):
newversion = True
else:
with open(cachedir + '/.version', 'rb') as cachev:
- if cachev.read().decode('utf8', 'replace').replace('\n', '') == KMS_VERSION:
+ if cachev.read().decode('utf8', 'replace').replace('\n', '') != KMS_VERSION:
newversion = True
if newversion:
for cached in os.listdir(cachedir):
@@ -826,6 +829,8 @@ def __kms(self, pony):
os.remove(cached)
with open(cachedir + '/.version', 'w+') as cachev:
cachev.write(KMS_VERSION)
+ if shared:
+ Popen('chmod 666 -- ' + _cachedir + '/.version', shell=True).wait()
## Get kmspony directory and kmspony file
kmsponies = cachedir + '/kmsponies/' + palettefile
@@ -848,16 +853,24 @@ def __kms(self, pony):
if not os.path.isfile(protokmspony):
if not os.path.isdir(protokmsponydir):
os.makedirs(protokmsponydir)
+ if shared:
+ Popen('chmod -R 6777 -- ' + _cachedir, shell=True).wait()
if not os.system('ponysay2ttyponysay < ' + _pony + ' > ' + _protokmspony) == 0:
sys.stderr.write('Unable to run ponysay2ttyponysay successfully, you need util-say for KMS support\n')
exit(1)
+ if shared:
+ Popen('chmod 666 -- ' + _protokmspony, shell=True).wait()
## Create kmspony
if not os.path.isdir(kmsponydir):
os.makedirs(kmsponydir)
+ if shared:
+ Popen('chmod -R 6777 -- ' + _cachedir, shell=True).wait()
if not os.system('tty2colourfultty -p ' + palette + ' < ' + _protokmspony + ' > ' + _kmspony) == 0:
sys.stderr.write('Unable to run tty2colourfultty successfully, you need util-say for KMS support\n')
exit(1)
+ if shared:
+ Popen('chmod 666 -- ' + _kmspony, shell=True).wait()
return kmspony
View
@@ -505,9 +505,9 @@ def install(self, conf):
print('Creating directory ' + dir)
os.mkdir(dir)
print('Setting permission mode mask for ' + dir + ' to 6777')
- Popen('chmod -R 6777 -- ' + dir, shell=True).wait()
+ Popen('chmod -R 6777 -- \'' + dir.replace('\'', '\'\\\'\'') + '\'', shell=True).wait()
print('Setting group for ' + dir + ' users')
- Popen('chown -R :users -- ' + dir, shell=True).wait()
+ Popen('chown -R :users -- \'' + dir.replace('\'', '\'\\\'\'') + '\'', shell=True).wait()
for shell in [item[0] for item in shells]:
if conf[shell] is not None:
for command in commands:

0 comments on commit e600c3c

Please sign in to comment.