Git Product home page Git Product logo

Comments (9)

magical avatar magical commented on July 19, 2024 2

@psanford That code only applies if you use the -o option. If you redirect the output of age-keygen to a file, the shell creates the file and you can see the warning.

% umask         
002
% ./age-keygen >test.keys
Warning: writing to a world-readable file.
Consider setting the umask to 066 and trying again.
Public key: age1efnk2yn5zj0zffkthqsmzz7gv5e7gffkpqlmsg76qlger0satasscpg3zj
% ls -l test.keys 
-rw-rw-r--. 1 foo bar 189 Jan  2 11:25 test.keys

from age.

str4d avatar str4d commented on July 19, 2024 1

umask is an inverse mask of the permission bits

That's a very good point; the error message does say "umask", not "mode". That is terribly unusable; I know of no way to directly set a umask in the CLI, whereas I expect every user will turn to chmod and stick that value in (as I did), because it looks so close to a common mode.

Perhaps the error should instead give an example command for the user to run? Either one that uses the umask, or a chmod 600 FILENAME.

from age.

magical avatar magical commented on July 19, 2024 1

I know of no way to directly set a umask in the CLI

$ umask 066

should work in any POSIX shell.

from age.

magical avatar magical commented on July 19, 2024 1

Perhaps an better solution is to suggest that users use the -o option to specify the output file, in which case age-keygen creates the file, not the shell, and can set the correct permissions.

from age.

magical avatar magical commented on July 19, 2024

It looks right to me as is. umask is an inverse mask of the permission bits, so a umask of 066 should clear the read and write bits of any new files for the group and other users but not the owner.

from age.

magical avatar magical commented on July 19, 2024

I believe the reason the warning suggests umask instead of chmod is so that the file will never exist with too-broad permissions. If you chmod it after the fact, another user on the machine could read the contents between when the key is generated and when the permissions are changed.

from age.

Maryse47 avatar Maryse47 commented on July 19, 2024

I think the warning is indeed confusing but for different reason: umask should be 077.

066 will leave execution rights which doesn't make sense.

from age.

str4d avatar str4d commented on July 19, 2024
$ umask 066

should work in any POSIX shell.

Oh cool, this is something I'd never come across! Which exactly makes my point: the error message shouldn't assume that users are familiar with obscure Unix-specific functionality.

from age.

psanford avatar psanford commented on July 19, 2024

@str4d did you actually trigger the error message here? The code is already creating the file with limited permissions:

f, err := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600)

Its then doing a sanity check on the permissions after creation.

Given the 0600 FileMode It doesn't seem like it would be possible to actually hit this error case on a normal unix filesystem. (If you did somehow hit this error I don't see how the problem would actually be related to the process' umask).

from age.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.