Lines 9-15
Link Here
|
9 |
|
9 |
|
10 |
import errno, os, stat, time, types |
10 |
import errno, os, stat, time, types |
11 |
from portage.exception import DirectoryNotFound, FileNotFound, \ |
11 |
from portage.exception import DirectoryNotFound, FileNotFound, \ |
12 |
InvalidData, TryAgain |
12 |
InvalidData, TryAgain, OperationNotPermitted, PermissionDenied |
13 |
from portage.data import portage_gid |
13 |
from portage.data import portage_gid |
14 |
from portage.output import EOutput |
14 |
from portage.output import EOutput |
15 |
from portage.util import writemsg |
15 |
from portage.util import writemsg |
Lines 55-76
Link Here
|
55 |
if type(mypath) == types.StringType: |
55 |
if type(mypath) == types.StringType: |
56 |
if not os.path.exists(os.path.dirname(mypath)): |
56 |
if not os.path.exists(os.path.dirname(mypath)): |
57 |
raise DirectoryNotFound(os.path.dirname(mypath)) |
57 |
raise DirectoryNotFound(os.path.dirname(mypath)) |
58 |
if not os.path.exists(lockfilename): |
58 |
old_mask = os.umask(000) |
59 |
old_mask=os.umask(000) |
59 |
try: |
60 |
myfd = os.open(lockfilename, os.O_CREAT|os.O_RDWR,0660) |
|
|
61 |
try: |
60 |
try: |
|
|
61 |
myfd = os.open(lockfilename, os.O_CREAT|os.O_RDWR, 0660) |
62 |
except OSError, e: |
63 |
func_call = "open('%s')" % lockfilename |
64 |
if e.errno == OperationNotPermitted.errno: |
65 |
raise OperationNotPermitted(func_call) |
66 |
elif e.errno == PermissionDenied.errno: |
67 |
raise PermissionDenied(func_call) |
68 |
else: |
69 |
raise |
70 |
try: |
62 |
if os.stat(lockfilename).st_gid != portage_gid: |
71 |
if os.stat(lockfilename).st_gid != portage_gid: |
63 |
os.chown(lockfilename,os.getuid(),portage_gid) |
72 |
os.chown(lockfilename, os.getuid(), portage_gid) |
64 |
except OSError, e: |
73 |
except OSError, e: |
65 |
if e[0] == 2: # No such file or directory |
74 |
if e.errno == errno.ENOENT: # No such file or directory |
66 |
return lockfile(mypath, wantnewlockfile=wantnewlockfile, |
75 |
return lockfile(mypath, wantnewlockfile=wantnewlockfile, |
67 |
unlinkfile=unlinkfile, waiting_msg=waiting_msg, |
76 |
unlinkfile=unlinkfile, waiting_msg=waiting_msg, |
68 |
flags=flags) |
77 |
flags=flags) |
69 |
else: |
78 |
else: |
70 |
writemsg("Cannot chown a lockfile. This could cause inconvenience later.\n"); |
79 |
writemsg("Cannot chown a lockfile. This could " + \ |
|
|
80 |
"cause inconvenience later.\n") |
81 |
finally: |
71 |
os.umask(old_mask) |
82 |
os.umask(old_mask) |
72 |
else: |
|
|
73 |
myfd = os.open(lockfilename, os.O_CREAT|os.O_RDWR,0660) |
74 |
|
83 |
|
75 |
elif type(mypath) == types.IntType: |
84 |
elif type(mypath) == types.IntType: |
76 |
myfd = mypath |
85 |
myfd = mypath |