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

chmod() missing Julia-side #7574

Closed
staticfloat opened this issue Jul 11, 2014 · 14 comments · Fixed by #7590
Closed

chmod() missing Julia-side #7574

staticfloat opened this issue Jul 11, 2014 · 14 comments · Fixed by #7590
Assignees
Labels
help wanted Indicates that a maintainer wants help on an issue or pull request

Comments

@staticfloat
Copy link
Member

Alongside #7573, it seems that we do indeed have a chmod within libuv, but it's not wrapped in Julia at all. We should probably support that so that if we somehow manage to create a read-only file on Windows, we can make it writable so that we can delete it.

@tkelman
Copy link
Contributor

tkelman commented Jul 11, 2014

Quoting from https://github.com/joyent/libuv/blob/8d11aacb79472009189c35e8953d0fa316bfd202/src/win/fs.c#L867-L885:

  /* Todo: st_mode should probably always be 0666 for everyone. We might also
   * want to report 0777 if the file is a .exe or a directory.
   *
   * Currently it's based on whether the 'readonly' attribute is set, which
   * makes little sense because the semantics are so different: the 'read-only'
   * flag is just a way for a user to protect against accidental deleteion, and
   * serves no security purpose. Windows uses ACLs for that.
   *
   * Also people now use uv_fs_chmod() to take away the writable bit for good
   * reasons. Windows however just makes the file read-only, which makes it
   * impossible to delete the file afterwards, since read-only files can't be
   * deleted.
   *
   * IOW it's all just a clusterfuck and we should think of something that
   * makes slighty more sense.
   *
   * And uv_fs_chmod should probably just fail on windows or be a total no-op.
   * There's nothing sensible it can do anyway.
   */

Hmm.

@jakebolewski
Copy link
Member

Wow I didn't realize things were this broken.

@tkelman tkelman self-assigned this Jul 12, 2014
@tkelman
Copy link
Contributor

tkelman commented Jul 12, 2014

I can do this one. Does it need a jl_fs_chmod wrapper in C, or should it be a straight ccall to libuv the way open is done?

@tkelman
Copy link
Contributor

tkelman commented Jul 13, 2014

Question: does anybody want/use/understand = or X flags in chmod? I have chmod(mode::Integer, p::String) more or less working, but chmod(mode::String, p::String) is more code and I'm not sure I can correctly do anything more complicated than [ugoa][+-][rwxst]. How complete an implementation should we aim for?

@jakebolewski
Copy link
Member

chmod + string support I feel is a non-essential feature. This could always be added later. I vote keep it simple for the time being so this gets merged soon.

@StefanKarpinski
Copy link
Member

Interactively, I use X with recursive chmod all the time. Not sure if it's that useful programmatically.

@jakebolewski
Copy link
Member

@tkelman will chmod at least let us delete readonly files on Windows or is this going to be broken? I thought that the above comment was more about file permissions.

@tkelman
Copy link
Contributor

tkelman commented Jul 13, 2014

@jakebolewski in my testing switching the 0o200 bit is able to turn on and off the read-only property, so I think it'll be good enough. I'll submit a numeric-only chmod PR in a couple minutes.

@tkelman
Copy link
Contributor

tkelman commented Jul 13, 2014

Crap. Python argument order chmod(path, mode), or command line order chmod(mode, path) ?

@jakebolewski
Copy link
Member

+1 for python order

@elextr
Copy link

elextr commented Jul 13, 2014

(mode, path...)?

tkelman added a commit to tkelman/julia that referenced this issue Jul 13, 2014
currently only integer modes, can do string modes like +x later
fixes JuliaLang#7574
@tkelman
Copy link
Contributor

tkelman commented Jul 13, 2014

We could also do (paths... ; mode = mode) but for a first cut I was only going to do a single file at a time. Most of the other functions in base/fs.jl don't have varargs versions yet.

@StefanKarpinski
Copy link
Member

Most of our path and file stuff follows Python, so I'm inclined to follow Python here too.

tkelman added a commit to tkelman/julia that referenced this issue Jul 26, 2014
currently only integer modes, can do string modes like +x later
fixes JuliaLang#7574
tkelman added a commit that referenced this issue Nov 23, 2014
currently only integer modes, can do string modes like +x later
fixes #7574

Conflicts:
	src/jl_uv.c
tkelman added a commit that referenced this issue Nov 23, 2014
currently only integer modes, can do string modes like +x later
fixes #7574

Conflicts:
	src/jl_uv.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Indicates that a maintainer wants help on an issue or pull request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants