Skip to content

Commit 4a696df

Browse files
committed
Fix bug if file has other permissions than the directory. Also better error handling
1 parent 19ba129 commit 4a696df

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

nxc/protocols/nfs.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ def put_file(self):
495495
file_data = file.read().decode()
496496

497497
# Write the data to the remote file
498-
self.logger.display(f"Trying to write data from {local_file_path} to {remote_file_path}")
498+
self.logger.info(f"Trying to write data from {local_file_path} to {remote_file_path}")
499499
res = self.nfs3.write(file_handle, 0, len(file_data), file_data, 1, auth=self.auth)
500500
if res["status"] != 0:
501501
self.logger.fail(f"Error writing to {remote_file_path}: {NFSSTAT3[res['status']]}")
@@ -646,7 +646,13 @@ def ls(self):
646646
break
647647
curr_fh = res["resok"]["object"]["data"]
648648

649+
# Update the UID and GID for the file/dir
650+
self.update_auth(curr_fh)
651+
649652
dir_listing = self.nfs3.readdirplus(curr_fh, auth=self.auth)
653+
if dir_listing["status"] != 0:
654+
self.logger.fail(f"Error on listing directory: {NFSSTAT3[dir_listing['status']]}")
655+
return
650656
content = self.format_directory(dir_listing)
651657

652658
# Sometimes the NFS Server does not return the attributes for the files
@@ -677,8 +683,6 @@ def print_directory(self, content, path):
677683
self.logger.highlight(f"{'UID':<11}{'Perms':<7}{'File Size':<14}{'File Path'}")
678684
self.logger.highlight(f"{'---':<11}{'-----':<7}{'---------':<14}{'---------'}")
679685
for item in content:
680-
if item["name"] in [b".", b".."]:
681-
continue
682686
if not item["name_attributes"]["present"] or not item["name_handle"]["present"]:
683687
uid = "-"
684688
perms = "----"

0 commit comments

Comments
 (0)