Lines 4139-4147
Link Here
|
4139 |
if bsd_chflags: |
4139 |
if bsd_chflags: |
4140 |
if destexists and dstat.st_flags != 0: |
4140 |
if destexists and dstat.st_flags != 0: |
4141 |
bsd_chflags.lchflags(dest, 0) |
4141 |
bsd_chflags.lchflags(dest, 0) |
|
|
4142 |
# Use normal stat/chflags for the parent since we want to |
4143 |
# follow any symlinks to the real parent directory. |
4142 |
pflags = os.stat(os.path.dirname(dest)).st_flags |
4144 |
pflags = os.stat(os.path.dirname(dest)).st_flags |
4143 |
if pflags != 0: |
4145 |
if pflags != 0: |
4144 |
bsd_chflags.lchflags(os.path.dirname(dest), 0) |
4146 |
bsd_chflags.chflags(os.path.dirname(dest), 0) |
4145 |
|
4147 |
|
4146 |
if destexists: |
4148 |
if destexists: |
4147 |
if stat.S_ISLNK(dstat[stat.ST_MODE]): |
4149 |
if stat.S_ISLNK(dstat[stat.ST_MODE]): |
Lines 4248-4254
Link Here
|
4248 |
if bsd_chflags: |
4250 |
if bsd_chflags: |
4249 |
# Restore the flags we saved before moving |
4251 |
# Restore the flags we saved before moving |
4250 |
if pflags: |
4252 |
if pflags: |
4251 |
bsd_chflags.lchflags(os.path.dirname(dest), pflags) |
4253 |
bsd_chflags.chflags(os.path.dirname(dest), pflags) |
4252 |
|
4254 |
|
4253 |
return newmtime |
4255 |
return newmtime |
4254 |
|
4256 |
|
Lines 7437-7443
Link Here
|
7437 |
|
7439 |
|
7438 |
#process symlinks second-to-last, directories last. |
7440 |
#process symlinks second-to-last, directories last. |
7439 |
mydirs = [] |
7441 |
mydirs = [] |
|
|
7442 |
ignored_unlink_errnos = (errno.ENOENT, errno.EISDIR) |
7440 |
modprotect = os.path.join(self.vartree.root, "lib/modules/") |
7443 |
modprotect = os.path.join(self.vartree.root, "lib/modules/") |
|
|
7444 |
|
7445 |
def unlink(file_name, lstatobj): |
7446 |
if bsd_chflags: |
7447 |
if lstatobj.st_flags != 0: |
7448 |
bsd_chflags.lchflags(file_name, 0) |
7449 |
parent_name = os.path.dirname(file_name) |
7450 |
# Use normal stat/chflags for the parent since we want to |
7451 |
# follow any symlinks to the real parent directory. |
7452 |
pflags = os.stat(parent_name).st_flags |
7453 |
if pflags != 0: |
7454 |
bsd_chflags.chflags(parent_name, 0) |
7455 |
try: |
7456 |
if not stat.S_ISLNK(lstatobj.st_mode): |
7457 |
# Remove permissions to ensure that any hardlinks to |
7458 |
# suid/sgid files are rendered harmless. |
7459 |
os.chmod(file_name, 0) |
7460 |
os.unlink(file_name) |
7461 |
finally: |
7462 |
if bsd_chflags and pflags != 0: |
7463 |
# Restore the parent flags we saved before unlinking |
7464 |
bsd_chflags.chflags(parent_name, pflags) |
7465 |
|
7441 |
def show_unmerge(zing, desc, file_type, file_name): |
7466 |
def show_unmerge(zing, desc, file_type, file_name): |
7442 |
writemsg_stdout("%s %s %s %s\n" % \ |
7467 |
writemsg_stdout("%s %s %s %s\n" % \ |
7443 |
(zing, desc.ljust(8), file_type, file_name)) |
7468 |
(zing, desc.ljust(8), file_type, file_name)) |
Lines 7487-7499
Link Here
|
7487 |
not (islink and statobj and stat.S_ISDIR(statobj.st_mode)) and \ |
7512 |
not (islink and statobj and stat.S_ISDIR(statobj.st_mode)) and \ |
7488 |
not self.isprotected(obj): |
7513 |
not self.isprotected(obj): |
7489 |
try: |
7514 |
try: |
7490 |
# Remove permissions to ensure that any hardlinks to |
7515 |
unlink(obj, lstatobj) |
7491 |
# suid/sgid files are rendered harmless. |
|
|
7492 |
if statobj and not islink: |
7493 |
os.chmod(obj, 0) |
7494 |
os.unlink(obj) |
7495 |
except EnvironmentError, e: |
7516 |
except EnvironmentError, e: |
7496 |
pass |
7517 |
if e.errno not in ignored_unlink_errnos: |
|
|
7518 |
raise |
7519 |
del e |
7497 |
show_unmerge("<<<", "", file_type, obj) |
7520 |
show_unmerge("<<<", "", file_type, obj) |
7498 |
continue |
7521 |
continue |
7499 |
|
7522 |
|
Lines 7519-7527
Link Here
|
7519 |
# contents as a directory even if it happens to correspond |
7542 |
# contents as a directory even if it happens to correspond |
7520 |
# to a symlink when it's merged to the live filesystem. |
7543 |
# to a symlink when it's merged to the live filesystem. |
7521 |
try: |
7544 |
try: |
7522 |
os.unlink(obj) |
7545 |
unlink(obj, lstatobj) |
7523 |
show_unmerge("<<<", "", file_type, obj) |
7546 |
show_unmerge("<<<", "", file_type, obj) |
7524 |
except (OSError,IOError),e: |
7547 |
except (OSError, IOError),e: |
|
|
7548 |
if e.errno not in ignored_unlink_errnos: |
7549 |
raise |
7550 |
del e |
7525 |
show_unmerge("!!!", "", file_type, obj) |
7551 |
show_unmerge("!!!", "", file_type, obj) |
7526 |
elif pkgfiles[objkey][0] == "obj": |
7552 |
elif pkgfiles[objkey][0] == "obj": |
7527 |
if statobj is None or not stat.S_ISREG(statobj.st_mode): |
7553 |
if statobj is None or not stat.S_ISREG(statobj.st_mode): |
Lines 7541-7553
Link Here
|
7541 |
show_unmerge("---", "!md5", file_type, obj) |
7567 |
show_unmerge("---", "!md5", file_type, obj) |
7542 |
continue |
7568 |
continue |
7543 |
try: |
7569 |
try: |
7544 |
# Remove permissions to ensure that any hardlinks to |
7570 |
unlink(obj, lstatobj) |
7545 |
# suid/sgid files are rendered harmless. |
|
|
7546 |
if not islink: |
7547 |
os.chmod(obj, 0) |
7548 |
os.unlink(obj) |
7549 |
except (OSError,IOError),e: |
7571 |
except (OSError,IOError),e: |
7550 |
pass |
7572 |
if e.errno not in ignored_unlink_errnos: |
|
|
7573 |
raise |
7574 |
del e |
7551 |
show_unmerge("<<<", "", file_type, obj) |
7575 |
show_unmerge("<<<", "", file_type, obj) |
7552 |
elif pkgfiles[objkey][0] == "fif": |
7576 |
elif pkgfiles[objkey][0] == "fif": |
7553 |
if not stat.S_ISFIFO(lstatobj[stat.ST_MODE]): |
7577 |
if not stat.S_ISFIFO(lstatobj[stat.ST_MODE]): |
Lines 7562-7571
Link Here
|
7562 |
|
7586 |
|
7563 |
for obj in mydirs: |
7587 |
for obj in mydirs: |
7564 |
try: |
7588 |
try: |
7565 |
os.rmdir(obj) |
7589 |
if bsd_chflags: |
|
|
7590 |
lstatobj = os.lstat(obj) |
7591 |
if lstatobj.st_flags != 0: |
7592 |
bsd_chflags.lchflags(obj, 0) |
7593 |
parent_name = os.path.dirname(obj) |
7594 |
# Use normal stat/chflags for the parent since we want to |
7595 |
# follow any symlinks to the real parent directory. |
7596 |
pflags = os.stat(parent_name).st_flags |
7597 |
if pflags != 0: |
7598 |
bsd_chflags.chflags(parent_name, 0) |
7599 |
try: |
7600 |
os.rmdir(obj) |
7601 |
finally: |
7602 |
if bsd_chflags and pflags != 0: |
7603 |
# Restore the parent flags we saved before unlinking |
7604 |
bsd_chflags.chflags(parent_name, pflags) |
7566 |
show_unmerge("<<<", "", "dir", obj) |
7605 |
show_unmerge("<<<", "", "dir", obj) |
7567 |
except (OSError, IOError): |
7606 |
except EnvironmentError, e: |
7568 |
show_unmerge("---", "!empty", "dir", obj) |
7607 |
if e.errno not in (errno.ENOENT, |
|
|
7608 |
errno.EEXIST, errno.ENOTEMPTY, |
7609 |
errno.ENOTDIR): |
7610 |
raise |
7611 |
if e.errno != errno.ENOENT: |
7612 |
show_unmerge("---", "!empty", "dir", obj) |
7613 |
del e |
7569 |
|
7614 |
|
7570 |
#remove self from vartree database so that our own virtual gets zapped if we're the last node |
7615 |
#remove self from vartree database so that our own virtual gets zapped if we're the last node |
7571 |
self.vartree.zap(self.mycpv) |
7616 |
self.vartree.zap(self.mycpv) |