Changeset 2889
- Timestamp:
- 05/18/06 20:18:00 (19 years ago)
- Location:
- pykota/trunk
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r2886 r2889 255 255 self.JobId = sys.argv[1].strip() 256 256 # use CUPS' user when printing test pages from CUPS' web interface 257 self.UserName = sys.argv[2].strip() or pwd.getpwuid(os.geteuid())[0]257 self.UserName = sys.argv[2].strip() or self.originalUserName or pwd.getpwuid(os.geteuid())[0] 258 258 self.Title = sys.argv[3].strip() 259 259 self.Copies = int(sys.argv[4].strip()) -
pykota/trunk/pykota/tool.py
r2879 r2889 191 191 """Drops priviledges.""" 192 192 uid = os.geteuid() 193 if uid : 194 try : 195 username = pwd.getpwuid(uid)[0] 196 except (KeyError, IndexError), msg : 197 self.printInfo(_("Strange problem with uid(%s) : %s") % (uid, msg), "warn") 193 try : 194 self.originalUserName = pwd.getpwuid(uid)[0] 195 except (KeyError, IndexError), msg : 196 self.printInfo(_("Strange problem with uid(%s) : %s") % (uid, msg), "warn") 197 self.originalUserName = None 198 else : 199 if uid : 200 self.logdebug(_("Running as user '%s'.") % self.originalUserName) 198 201 else : 199 self.logdebug(_("Running as user '%s'.") % username) 200 else : 201 if self.pykotauser is None : 202 self.logdebug(_("No user named 'pykota'. Not dropping priviledges.")) 203 else : 204 try : 205 os.setegid(self.pykotauser[3]) 206 os.seteuid(self.pykotauser[2]) 207 except OSError, msg : 208 self.printInfo(_("Impossible to drop priviledges : %s") % msg, "warn") 202 if self.pykotauser is None : 203 self.logdebug(_("No user named 'pykota'. Not dropping priviledges.")) 209 204 else : 210 self.logdebug(_("Priviledges dropped. Now running as user 'pykota'.")) 211 self.privdropped = 1 205 try : 206 os.setegid(self.pykotauser[3]) 207 os.seteuid(self.pykotauser[2]) 208 except OSError, msg : 209 self.printInfo(_("Impossible to drop priviledges : %s") % msg, "warn") 210 else : 211 self.logdebug(_("Priviledges dropped. Now running as user 'pykota'.")) 212 self.privdropped = 1 212 213 213 214 def regainPriv(self) :