Skip to content
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

Add File Shred command #513

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sfc-gh-iyashchyshyn
Copy link
Collaborator

WIP
Adds shred sub-command to file command with support for zeroing-pass, file-removal and force-permissions-change flags.


// ShredRequest is a request to perform Shred operation on a specific file
message ShredRequest {
string filename = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this should be absolute path? Should we add a comment?

Btw it is a shame that this prot o file talks about filepath as filename everywhere. https://unix.stackexchange.com/questions/146895/filename-and-pathname-of-a-file

But since local consistency matters too, I guess it is better to keep it as filename.


args = append(args, req.Filename)

// we want to fail as soon as possible, if the file is unreadable, opened by someone else or something else happens
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there any alternative you considered here other than attempting shredding and returning error as Internal? I am trying to understand why this comment needs to be in place.

I think what you do here is reasonable, might be little weird that we return "Internal" for filenames that are not found, but we shouldn't go into business of parsing linux commands output(s).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to reasonably extend the localfile_test.go to cover shredding with some test case? (I guess some test on zero-ing without removal is something we could do)

// listed in one of the PATH's components, it will continue its operation and only return an error in case
// no paths were readable and/or executable couldn't be found in either of them.
// Note that it does not check whether a file is actually executable by current user.
func Which(exeName string) (string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For ansible, the choice so far was to hard-code the bin

AnsiblePlaybookBin = "/usr/bin/ansible-playbook"

do you expect us to have different shredding binary specified per user, hence we start to use which like approach? If so, we should probably sudo to the user first before resolving path?

(not sure if we need that, and if so we could just start with binding to /usr/bin/shred?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants