diff options
-rw-r--r-- | kpov_judge/tasks/smb_nfs/task.py | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/kpov_judge/tasks/smb_nfs/task.py b/kpov_judge/tasks/smb_nfs/task.py index 8769eae..1e6121b 100644 --- a/kpov_judge/tasks/smb_nfs/task.py +++ b/kpov_judge/tasks/smb_nfs/task.py @@ -77,9 +77,42 @@ params_meta = { } def task(SMB_NAME, NFS_MOUNT, SHARED_FILENAME, SHARED_FILENAME_CONTENT): - # mount the NFS mount - # mount the SMB mount - # read the filename content + import subprocess + + # Naslov, na katerem se nahaja streznik. + address = SMB_NAME + # Tabela vseh mountov. + mounts = subprocess.check_output("mount").split("\n") + # Samo mounti na streznik. + srvmounts = [] + for m in mounts: + if str.find(m, address) >= 0: + srvmounts.append(m) + # Mounti so v formatu: + # ["//SMB_NAME/<pot_do_direktorija> on NFS_MOUNT type cifs (rw)", ... ] + # example: ["//192.168.1.92/srv/samba on /mnt/samba type cifs (rw)", ... ] + # Seznam mora imeti vnos za NFS in SMB, morata biti obesena na pravo pot in (rw) + for m in srvmounts: + # Dobimo pot, filesystem in pravice iz mounta: + split = m.split() + pot = split[2] + fstype = split[4] + pravice = split[5] + # Pregledamo datoteke v temu direktoriju: + ls = subprocess.check_output(["ls", pot]).split() + # Preverimo ce je v imeniku datoteka: + if SHARED_FILENAME in ls: + # Če je, primerjamo vsebino: + cat = subprocess.check_output(["cat", pot+"/"+SHARED_FILENAME]) + if cat == SHARED_FILENAME_CONTENT: + # DING DING DING PLUS PIKE ZA PRAVO VSEBINO + pass + if pravice == "(rw)": + # BONUS PIKE ZA READ/WRITE PRAVICE + pass + + # Samo delno stestirano! + results = ''.join(random.choice(string.ascii_uppercase) for i in range(12)) #results = "test" return results |