-
Notifications
You must be signed in to change notification settings - Fork 500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PasswordProtectedFiles #5067
PasswordProtectedFiles #5067
Changes from 3 commits
56418a3
ccea176
5ae29af
19ba053
093914b
d06f0a5
b609ece
8af142c
121103e
2b4bd2b
45fa2d4
f1da4d8
fb816e4
3c00491
49dc58a
7c83d5f
8faefc1
28de024
43ec5f7
1ec8efc
8218fcb
17852bb
75e5820
af8cc38
f23c03d
b867b90
d789693
0fb1088
c5eac59
65faf44
5de0a28
4d5c59f
e26199a
38d917f
79ae330
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[LocalizedFileNames] | ||
file_browser.dm=@file_browser.dm,0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,18 @@ | |
|
||
if(href_list["PRG_openfile"]) | ||
. = 1 | ||
open_file = href_list["PRG_openfile"] | ||
var/obj/item/weapon/computer_hardware/hard_drive/HDD = computer.hard_drive | ||
var/datum/computer_file/file = HDD.find_file_by_name(href_list["PRG_openfile"]) | ||
var/checkpass = "" | ||
var/currentpass = file.password | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unsafe access of file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do I make a proc to check for the password? Also I dont understand what you mean by unsafe acess of file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should make password protection validation a proc, yes. This method of doing: if (!currentpass)
// do one thing
else
// check password and do the other is bad. Very bad. A file should have a proc Rough contents would look like this: /datum/computer_file/proc/can_access_file(mob/user, prompt_for_password = FALSE, input_password = "")
if (!password)
return TRUE
if (prompt_for_password)
if (!ismob(user))
return FALSE
input_password = sanitize(input(user, "Please enter a password to access file '[name]':"))
return password == input_password This allows for 100x cleaner functionality: if (!file.can_access_file(usr, TRUE))
return 1
open_file = href_list["PRG_openfile"] |
||
if(!currentpass) | ||
open_file = href_list["PRG_openfile"] | ||
else | ||
checkpass = sanitize(input(usr, "Please enter the password:")) | ||
if(checkpass == currentpass) | ||
open_file = href_list["PRG_openfile"] | ||
else | ||
return 1 | ||
if(href_list["PRG_newtextfile"]) | ||
. = 1 | ||
var/newname = sanitize(input(usr, "Enter file name or leave blank to cancel:", "File rename")) | ||
|
@@ -28,28 +39,48 @@ | |
var/obj/item/weapon/computer_hardware/hard_drive/HDD = computer.hard_drive | ||
if(!HDD) | ||
return 1 | ||
var/newpassword = sanitize(input(usr, "Enter a password or leave blank to leave unprotected:")) | ||
var/datum/computer_file/data/F = new/datum/computer_file/data() | ||
F.filename = newname | ||
F.filetype = "TXT" | ||
F.password = newpassword | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should do |
||
HDD.store_file(F) | ||
if(href_list["PRG_deletefile"]) | ||
. = 1 | ||
var/obj/item/weapon/computer_hardware/hard_drive/HDD = computer.hard_drive | ||
if(!HDD) | ||
return 1 | ||
var/datum/computer_file/file = HDD.find_file_by_name(href_list["PRG_deletefile"]) | ||
var/checkpass = "" | ||
var/currentpass = file.password | ||
if(!file || file.undeletable) | ||
return 1 | ||
HDD.remove_file(file) | ||
if(!currentpass) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deleting shouldn't require password There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I disagree, bald greytide names steve breaks into the captains office and logs onto his computer, baldie mcsteve finds file names "realy important information i need to remember and cannot be deleted" baldie mcsteve deleted the file and runs to his greytide layer. The captain returns and finds his file has been deleted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Password protected files IRL ask for a password every time you so much as breathe on it. It requires a password when you move the file or delete the file. It makes sense that password protected files ask for a password every time you modify it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would depend on what the actual underlying mentality of the password protection is. There's two ways to handle password protection:
I don't really have a preference, @Arrow768 might have one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am thinking of revealing encrypted ciphertext during an emag then having the player decrypt the file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regarding password required for deletion: I believe the second option is our way to go in that case: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regarding Baldie McSteve. |
||
HDD.remove_file(file) | ||
else | ||
checkpass = sanitize(input(usr, "Please enter the password:")) | ||
if(checkpass == currentpass) | ||
HDD.remove_file(file) | ||
else | ||
return 1 | ||
if(href_list["PRG_usbdeletefile"]) | ||
. = 1 | ||
var/obj/item/weapon/computer_hardware/hard_drive/RHDD = computer.portable_drive | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again, this change needs to be explained. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was reverted from the previos push |
||
if(!RHDD) | ||
return 1 | ||
var/datum/computer_file/file = RHDD.find_file_by_name(href_list["PRG_usbdeletefile"]) | ||
var/checkpass = "" | ||
var/currentpass = file.password | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't know if the file exists. Move this below line 76. |
||
if(!file || file.undeletable) | ||
return 1 | ||
RHDD.remove_file(file) | ||
if(!currentpass) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing about deleting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the thing about deleting files in flash drive as you cant find them or make them i dont think. |
||
RHDD.remove_file(file) | ||
else | ||
checkpass = sanitize(input(usr, "Please enter the password:")) | ||
if(checkpass == currentpass) | ||
RHDD.remove_file(file) | ||
else | ||
return 1 | ||
if(href_list["PRG_closefile"]) | ||
. = 1 | ||
open_file = null | ||
|
@@ -60,21 +91,40 @@ | |
if(!HDD) | ||
return 1 | ||
var/datum/computer_file/F = HDD.find_file_by_name(href_list["PRG_clone"]) | ||
var/checkpass = "" | ||
var/currentpass = F.password | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're accessing |
||
if(!F || !istype(F)) | ||
return 1 | ||
var/datum/computer_file/C = F.clone(1) | ||
HDD.store_file(C) | ||
if(!currentpass) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you opened file, you already know password, so closing it shouldn't ask password too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is for cloning the file, not closing it. |
||
HDD.store_file(C) | ||
else | ||
checkpass = sanitize(input(usr, "Please enter the password:")) | ||
if(checkpass == currentpass) | ||
HDD.store_file(C) | ||
else | ||
return 1 | ||
if(href_list["PRG_rename"]) | ||
. = 1 | ||
var/obj/item/weapon/computer_hardware/hard_drive/HDD = computer.hard_drive | ||
if(!HDD) | ||
return 1 | ||
var/datum/computer_file/file = HDD.find_file_by_name(href_list["PRG_rename"]) | ||
var/checkpass = "" | ||
var/currentpass = file.password | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Below line 117. |
||
if(!file || !istype(file)) | ||
return 1 | ||
var/newname = sanitize(input(usr, "Enter new file name:", "File rename", file.filename)) | ||
if(file && newname) | ||
file.filename = newname | ||
if(!currentpass) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Renaming shouldn't need password There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Baldie McSteve will strike again. |
||
if(file && newname) | ||
file.filename = newname | ||
else | ||
checkpass = sanitize(input(usr, "Please enter the password:")) | ||
if(checkpass == currentpass) | ||
if(file && newname) | ||
file.filename = newname | ||
else | ||
return 1 | ||
if(href_list["PRG_edit"]) | ||
. = 1 | ||
if(!open_file) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,37 @@ | ||
################################ | ||
# Example Changelog File | ||
# | ||
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. | ||
# | ||
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) | ||
# When it is, any changes listed below will disappear. | ||
# | ||
# Valid Prefixes: | ||
# bugfix | ||
# wip (For works in progress) | ||
# tweak | ||
# soundadd | ||
# sounddel | ||
# rscadd (general adding of nice things) | ||
# rscdel (general deleting of nice things) | ||
# imageadd | ||
# imagedel | ||
# maptweak | ||
# spellcheck (typo fixes) | ||
# experiment | ||
# balance | ||
################################# | ||
|
||
# Your name. | ||
author: N3X15 | ||
|
||
# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. | ||
delete-after: True | ||
|
||
# Any changes you've made. See valid prefix list above. | ||
# INDENT WITH TWO SPACES. NOT TABS. SPACES. | ||
# SCREW THIS UP AND IT WON'T WORK. | ||
# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. | ||
# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. | ||
changes: | ||
- rscadd: "Added a changelog editing system that should cause fewer conflicts and more accurate timestamps." | ||
- rscdel: "Killed innocent kittens." | ||
################################ | ||
# Example Changelog File | ||
# | ||
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. | ||
# | ||
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) | ||
# When it is, any changes listed below will disappear. | ||
# | ||
# Valid Prefixes: | ||
# bugfix | ||
# wip (For works in progress) | ||
# tweak | ||
# soundadd | ||
# sounddel | ||
# rscadd (general adding of nice things) | ||
# rscdel (general deleting of nice things) | ||
# imageadd | ||
# imagedel | ||
# maptweak | ||
# spellcheck (typo fixes) | ||
# experiment | ||
# balance | ||
################################# | ||
|
||
# Your name. | ||
author: dapocalypse | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DO NOT EDIT There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It´s now a different file |
||
|
||
# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. | ||
delete-after: True | ||
|
||
# Any changes you've made. See valid prefix list above. | ||
# INDENT WITH TWO SPACES. NOT TABS. SPACES. | ||
# SCREW THIS UP AND IT WON'T WORK. | ||
# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. | ||
# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. | ||
changes: | ||
- rscadd: "Added a password protection system for files on modular computers." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary file