- new parameter -u / --user added, thx goes to Wolfang Eul for the patch!

git-svn-id: https://svn.ibp.de/svn/capisuite/trunk/capisuite@108 4ebea2bb-67d4-0310-8558-a5799e421b66
This commit is contained in:
gernot 2003-04-27 13:15:48 +00:00
parent cf10a812dd
commit 4bc12e751a
1 changed files with 18 additions and 6 deletions

View File

@ -4,7 +4,7 @@
# --------------------------------------------------- # ---------------------------------------------------
# copyright : (C) 2002 by Gernot Hillier # copyright : (C) 2002 by Gernot Hillier
# email : gernot@hillier.de # email : gernot@hillier.de
# version : $Revision: 1.3 $ # version : $Revision: 1.4 $
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -17,6 +17,7 @@ import cs_helpers
dialstring="" dialstring=""
abort="" abort=""
user=""
quiet=0 quiet=0
listqueue=0 listqueue=0
useprefix=1 useprefix=1
@ -25,7 +26,7 @@ def usage(error=""):
print """capisuitefax - capisuite tool for enqueueing faxes print """capisuitefax - capisuite tool for enqueueing faxes
usage: usage:
capisuitefax [-q] [-n] -d <dial> file1 [file2...] or capisuitefax [-q] [-n] [-u <user>] -d <dial> file1 [file2...] or
capisuitefax [-q] -a <id> or capisuitefax [-q] -a <id> or
capisuitefax [-h] [-l] capisuitefax [-h] [-l]
@ -37,6 +38,7 @@ possible options are:
-l, --list print jobs in the send queue -l, --list print jobs in the send queue
-n, --noprefix ignore configured dial prefix for this call -n, --noprefix ignore configured dial prefix for this call
(for internal calls) (for internal calls)
-u <user>, --user=<user> send fax as <user> (only when called as root!)
-q, --quiet be quiet, don't output informational messages -q, --quiet be quiet, don't output informational messages
The given files must be in Adobe PostScript format""" The given files must be in Adobe PostScript format"""
@ -99,8 +101,8 @@ def abortjob(config,user,job):
try: try:
optlist,args = getopt.getopt(sys.argv[1:], "d:a:lhqn" optlist,args = getopt.getopt(sys.argv[1:], "d:a:u:lhqn"
,['dialstring=','noprefix','help',"abort=","list","quiet"]) ,['dialstring=','noprefix','help',"abort=","list","quiet","user="])
except getopt.GetoptError, e: except getopt.GetoptError, e:
usage(e.msg) usage(e.msg)
@ -113,6 +115,12 @@ for option,param in optlist:
if option in ('-l','--list'): listqueue=1 if option in ('-l','--list'): listqueue=1
if option in ('-a','--abort'): abort=param if option in ('-a','--abort'): abort=param
if option in ('-q','--quiet'): quiet=1 if option in ('-q','--quiet'): quiet=1
if option in ('-u','--user'):
if (os.getuid()==0):
user=param
else:
usage("--user may only used as root!")
if (not abort and not listqueue and not dialstring): if (not abort and not listqueue and not dialstring):
usage("No usable command given.") usage("No usable command given.")
@ -127,7 +135,8 @@ if (dialstring and len(args)==0):
# test if this user is allowed to send faxes # test if this user is allowed to send faxes
config=cs_helpers.readConfig() config=cs_helpers.readConfig()
user=pwd.getpwuid(os.getuid())[0] if (user==""):
user=pwd.getpwuid(os.getuid())[0]
if (not config.has_section(user)): if (not config.has_section(user)):
print "Sorry, you're no valid user for CapiSuite" print "Sorry, you're no valid user for CapiSuite"
sys.exit(1) sys.exit(1)
@ -183,5 +192,8 @@ for i in args:
+"user=\""+user+"\"\n") +"user=\""+user+"\"\n")
os.chmod(newname,0600) os.chmod(newname,0600)
os.chmod(newname[:-3]+"txt",0600) os.chmod(newname[:-3]+"txt",0600)
if (os.getuid()==0):
user_entry=pwd.getpwnam(user)
os.chown(newname,user_entry[2],user_entry[3])
os.chown(newname[:-3]+"txt",user_entry[2],user_entry[3])
print i,"successful enqueued as",newname,"for",dialstring print i,"successful enqueued as",newname,"for",dialstring