News for hackers. Stuff that matters.
Re:Unveil(2) – Unveil parts of a restricted filesystem view by danieldk on Thursday July 19, 2018 @05:26AM (#17564862)
But compiler errors (typo in a flag) become runtime errors (typo in the unveil string).
Re:Unveil(2) – Unveil parts of a restricted filesystem view by tedunangst on Thursday July 19, 2018 @09:31AM (#17566062)
You're only one character away from FLAG1 || FLAG2.
Re:Unveil(2) – Unveil parts of a restricted filesystem view by protomyth on Thursday July 19, 2018 @06:29AM (#17565087)
It is trivial to run a script to check the values are correct.
Re:Unveil(2) – Unveil parts of a restricted filesystem view by temprature on Thursday July 19, 2018 @01:05PM (#17568349)
It's also pretty trivial to run the program. Maybe it's different in other projects, but I'm pretty sure in OpenBSD you're encouraged to actually test the code, not just ship it because it compiles. There's 2 programs in OpenBSD's base that don't abort on the pledge call failing, they're both shells, and they don't fail quietly.
Re:Unveil(2) – Unveil parts of a restricted filesystem view by vageli on Thursday July 19, 2018 @08:29AM (#17565601)
You don't see an issue with needing to write and maintain a verification script for something that is essentially a solved problem? Why add more development runtime overhead? What do string-based flags get you that bit-based don't?
Re:Unveil(2) – Unveil parts of a restricted filesystem view by temprature on Thursday July 19, 2018 @01:23PM (#17568519)
Removes the need to add a separate include for namespacing, ie. no pledge.h header needed.

Makes the calls shorter and easier to read. Consider:

    if (pledge("stdio rpath tmppath proc exec", NULL) == -1)
        err(1, "pledge");
vs.

    if (pledge(PLEDGE_STDIO | PLEDGE_RPATH | PLEDGE_TMPPATH | PLEDGE_PROC | PLEDGE_EXEC, NULL) == -1)
        err(1, "pledge");
Makes it easier to add a pledge interface to other languages with having to keep chasing bit flag changes, ie. there's been several new promises add since 2015 but the OpenBSD::Pledge perl module hasn't needed to change.

And really, unless you're using pledge wrong, ie. by using it outside of the startup path and/or not checking the return value, what does compile-time checking get you?

Re:Unveil(2) – Unveil parts of a restricted filesystem view by protomyth on Thursday July 19, 2018 @09:18AM (#17565954)
Nope, I really don't. I don't fear strings in code because I have to run verification scripts on whatever config format we end up using or you get stuff like [1]. Its just another part of the compile process once setup, and their reasoning was sound[2], so why stress. Heck, the script isn't even complicated.

Now, at a language level, would I like the C committee to start looking at some of these things? Yes, but why bother hoping for miracles.

1) https://www.engadget.com/2018/07/13/aliens-colonial-marines-...

2) https://www.tedunangst.com/flak/post/string-interfaces

Re:Unveil(2) – Unveil parts of a restricted filesystem view by fbender on Friday July 20, 2018 @07:27AM (#17574091)
If I’m not mistaken, you can even have the best of both worlds in languages with proper macro support (I’m sure you know which lang I‘m talking about): The Macro call can take the string input and „desugar“ it into bitmasks / function calls / whatever you need at compile time. Then you have:

1) easily readable, string-like input; 2) built-in-your-code verification and 3) compile-time check; 4) zero-overhead execution.

Just reading Ted‘s blog post gave me an idea how lang-specific libraries / (thin-layer) abstractions (or simply additional magic helper functionality) can improve upon legacy API designs (e.g. the GLX example) by using lang-specific functionality I never knew I‘d need or even cared about. Sometimes one can learn when you‘d never expect it. :D

Unless I‘m mistaken and misunderstood the whole thing, please correct me in that case.

Re:Unveil(2) – Unveil parts of a restricted filesystem view by protomyth on Saturday July 21, 2018 @05:20PM (#17583912)
I think the issue is that for most languages you have to update the libraries with the new constants for bit-wise operations and not for the string approach. Some languages would be fine, but this is multi-language in the end.