quick fix cmedb export share

main
mpgn 2022-09-22 18:24:27 -04:00
parent 35fb7f298f
commit 105ad97947
4 changed files with 6 additions and 7 deletions

View File

@ -94,7 +94,7 @@ class DatabaseNavigator(cmd.Cmd):
shares = self.db.get_shares()
with open(os.path.expanduser(line[2]), 'w') as export_file:
shareCSV = csv.writer(export_file, delimiter=";", quoting=csv.QUOTE_ALL, lineterminator='\n')
csv_header = ["id","computerid","userid","name","remark","read","write"]
csv_header = ["id","computer","userid","name","remark","read","write"]
shareCSV.writerow(csv_header)
#id|computerid|userid|name|remark|read|write
for share in shares:
@ -107,7 +107,7 @@ class DatabaseNavigator(cmd.Cmd):
#id|computerid|userid|name|remark|read|write
with open(os.path.expanduser(line[2]), 'w') as export_file:
shareCSV = csv.writer(export_file, delimiter=";", quoting=csv.QUOTE_ALL, lineterminator='\n')
csv_header = ["id","computerid","userid","name","remark","read","write"]
csv_header = ["id","computer","userid","name","remark","read","write"]
shareCSV.writerow(csv_header)
for share in shares:
shareid,hostname,userid,sharename,shareremark,read,write = share

View File

@ -666,7 +666,7 @@ class smb(connection):
if share_name != "IPC$":
try:
self.db.add_share(computer_id, self.host, share_name, share_remark, read, write)
self.db.add_share(self.hostname, user_id, share_name, share_remark, read, write)
except:
pass

View File

@ -66,13 +66,12 @@ class database:
db_conn.execute('''CREATE TABLE "shares" (
"id" integer PRIMARY KEY,
"computerid" integer,
"computerid" text,
"userid" integer,
"name" text,
"remark" text,
"read" boolean,
"write" boolean,
FOREIGN KEY(computerid) REFERENCES computers(id),
FOREIGN KEY(userid) REFERENCES users(id)
UNIQUE(computerid, userid, name)
)''')

View File

@ -67,7 +67,7 @@ class navigator(DatabaseNavigator):
def display_shares(self, shares):
data = [["ShareID", "Name", "Remark", "Read Access", "Write Access"]]
data = [["ShareID", "computer", "Name", "Remark", "Read Access", "Write Access"]]
for share in shares:
@ -88,7 +88,7 @@ class navigator(DatabaseNavigator):
permissions='w'
)
data.append([shareID, name, remark, f"{len(users_r_access)} User(s)", f"{len(users_w_access)} Users"])
data.append([shareID, computerid, name, remark, f"{len(users_r_access)} User(s)", f"{len(users_w_access)} Users"])
self.print_table(data)