Skip to content
Permalink
Browse files

Fix log file permissions, only change permissions or owners if needed

  • Loading branch information
simoncadman committed Feb 23, 2014
1 parent e2326ea commit b954621c57953705b97b228b0906e501996baf49
Showing with 29 additions and 22 deletions.
  1. +19 −14 auth.py
  2. +1 −1 backend.py
  3. +2 −0 ccputils.py
  4. +1 −1 deleteaccount.py
  5. +1 −1 dynamicppd.py
  6. +1 −1 listcloudprinters.py
  7. +1 −1 listdrivefiles.py
  8. +1 −1 reportissues.py
  9. +1 −1 setupcloudprint.py
  10. +1 −1 upgrade.py
33 auth.py
@@ -99,21 +99,26 @@ def AddAccount(storage, userid=None):
def FixFilePermissions(filename):
filePermissions = True
fileOwnerships = True
currentStat = None
if os.path.exists(filename):
currentStat = os.stat(filename)

try:
os.chmod(filename, 0660)
except:
filePermissions = False
sys.stderr.write("DEBUG: Cannot alter "+ filename +" file permissions\n")
pass

try:
os.chown(filename, -1, Auth.GetLPID())
except:
fileOwnerships = False
sys.stderr.write("DEBUG: Cannot alter "+ filename +" file ownership\n")
pass

if currentStat == None or currentStat.st_mode != 0100660:
try:
os.chmod(filename, 0100660)
except:
filePermissions = False
sys.stderr.write("DEBUG: Cannot alter "+ filename +" file permissions\n")
pass

if currentStat == None or currentStat.st_gid != Auth.GetLPID():
try:
os.chown(filename, -1, Auth.GetLPID())
except:
fileOwnerships = False
sys.stderr.write("DEBUG: Cannot alter "+ filename +" file ownership\n")
pass

return filePermissions, fileOwnerships

FixFilePermissions = staticmethod(FixFilePermissions)
@@ -22,7 +22,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20140223 130930"
CCPVersion = "20140223 140758"
print "CUPS Cloud Print CUPS Backend Version " + CCPVersion
sys.exit(0)

@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import subprocess, os, logging
from auth import Auth

class Utils:

@@ -28,6 +29,7 @@ def SetupLogging(logpath=None):
logpath = Utils.logpath
try:
logging.basicConfig(filename=logpath,level=logging.INFO,format=logformat,datefmt=dateformat)
Auth.FixFilePermissions(logpath)
except:
logging.basicConfig(level=logging.INFO,format=logformat,datefmt=dateformat)
logging.error("Unable to write to log file "+ logpath)
@@ -22,7 +22,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20140223 130930"
CCPVersion = "20140223 140758"
print "CUPS Cloud Print Delete Account Script Version " + CCPVersion
sys.exit(0)

@@ -20,7 +20,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20140223 130930"
CCPVersion = "20140223 140758"
print "CUPS Cloud Print Dynamic PPD Generator Version " + CCPVersion
sys.exit(0)

@@ -26,7 +26,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20140223 130930"
CCPVersion = "20140223 140758"
print "CUPS Cloud Print Printer Lister Version " + CCPVersion
sys.exit(0)

@@ -22,7 +22,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20140223 130930"
CCPVersion = "20140223 140758"
print "CUPS Cloud Print Printer Drive Lister Version " + CCPVersion
sys.exit(0)

@@ -21,7 +21,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20140223 130930"
CCPVersion = "20140223 140758"
print "CUPS Cloud Print Issue Reporting Script Version " + CCPVersion
sys.exit(0)

@@ -22,7 +22,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20140223 130930"
CCPVersion = "20140223 140758"
print "CUPS Cloud Print Setup Script Version " + CCPVersion
sys.exit(0)

@@ -41,7 +41,7 @@
printerItem = Printer(requestors)

# line below is replaced on commit
CCPVersion = "20140223 130930"
CCPVersion = "20140223 140758"

if len(sys.argv) == 2 and sys.argv[1] == 'version':
print "CUPS Cloud Print Upgrade Script Version " + CCPVersion

0 comments on commit b954621

Please sign in to comment.
You can’t perform that action at this time.