all 4 comments

sorted by: hot top controversial new old
[–] 10 points 6 months ago (3 children)

I didn't realize this was posted here.

Allow me to copy my comment from another thread:


// Don't bail on the first error, but remember the worst one.
let mut worst = 0;
for file in files {
    if let Err(e) = chmod_one(file) {
        worst = worst.max(e.exit_code());
    }
}
process::exit(worst);

This is not rustic, I feel.

files.iter()
  .map(chmod_one)
  .filter_map(Result::err)

is more like it.

From there, you can next() for first error, last() for last error, or fold() for max error, or collect() if you need to save all errors.


And no, static compilation doesn’t help here, because get_user_by_name goes through NSS, which dlopens libnss_* modules at runtime regardless of whether your binary is statically linked.

This is not true in musl systems. I just quickly checked in a Chimera rootfs (which has a system dynamic musl libc btw).

I believe the described dlopening is one of the well known reasons why GNU libc is not suitable for static linking, unlike musl!

In Arch, this indeed loads /usr/lib/libnss_systemd.so.2.

Everyone can test this with strace id 2>&1 | egrep 'open.*\.so'.

  • source
  • hideshow 3 child comments
  • [–] 0 points 6 months ago (2 children)

    In that for, all error messages have been lost. If to add such output “for” is the most elegant solution.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 6 months ago (1 child)

    No they're in the resulting iterator

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 5 months ago

    The usual handling in Rust afterwards is in most cases log one error or return to upstream “there was an error”. In some rare cases all errors returned as a single case.

    Both of these first are bad for i18n and finding what’s really happened in the middle.

  • source
  • parent
  • 11 comments in c/technology@lemmy.world view that post
    [–] 7 points 5 months ago (1 child)

    I was very confused by this sentence until I realized it's a programming thingy.

  • source
  • hideshow 1 child comment
  • [–] 5 points 5 months ago (2 children)

    I'm not a rust programmer, can anyone with experience in systems programming explain a legitimate use case for the uutils other than weakening the GPL? The auther even admits that several coreutils are still GNU in 26.04 which begs one to ask "why the rewrite?"

  • source
  • hideshow 2 child comments
  • [–] 5 points 5 months ago (1 child)

    The goal is to create a more secure version of the program. Since (safe) rust eliminates entire classes of security relevant bugs, a rust version has the potential to be much more secure that the C version. And since rust can eliminate entire classes of bugs, we can put more energy into finding bugs like the ones presented in the article.

    The weaker license is unfortunate, though.

  • source
  • parent
  • hideshow 1 child comment
  • [+] 0 points 5 months ago (6 children)
  • [–] 3 points 5 months ago (4 children)

    Wait, what? How? It compiles down to bare metal without a runtime. People write OSes and program microcontrollers with it. For any arbitrary C program, it's possible to write Rust code such that it compiles down to the same bytecode. Am I missing something?

  • source
  • parent
  • hideshow 4 child comments
  • [–] -3 points 5 months ago (3 children)

    Guess i've a different understanding of systems language.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 3 points 5 months ago (1 child)

    Wait, I'm so confused, what's your definition of a systems language?

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 5 months ago* (last edited 5 months ago)

    One you use to manipulate the system / solve problem efficiently, vs. creating GUIs. Which has heavy repercussions on what types of developers use it, how the ecosystem and language is built. One metric to distinguish them is new features / year; admin + hacker types want a stable & clever interface, companies and UI devs new features. And yeah, Rust is a bit of both of them, but has all the characteristics of the later.

    I have the feeling, you soon need a meta-language or extensive IDE-help to even use it. Just like C++.

    edit: In hindsight, this sounds more silly than i thought. There was a great article about it i can't find anymore, with the conclusion, that Rust is no systems language by that metric.

  • source
  • parent
  • 6 comments in c/linux@lemmy.ml view that post
    [–] 16 points 6 months ago* (last edited 6 months ago)

    This is an excellent article that breaks down common pitfalls and provides really concise rules for avoiding them. It's a great read if you're in to systems programming.

  • source
  • [–] 9 points 6 months ago

    As someone who is not at all into programming, this title made me genuinely think I had a stroke.

  • source
  • [–] 8 points 6 months ago (2 children)

    Those are bugs I dont think any programming language catch, unless it's a DSL for writing such programs on Linux or another OS.

  • source
  • hideshow 2 child comments
  • [–] [S] 3 points 6 months ago* (last edited 6 months ago)

    It could be improved. Sebastian Wick and Lennart Poettering made comments on how hard POSIX makes it hard to be secure. There are better APIs that try to be safer.

    And since uutils is not Linux only, it can't use these safer APIs directly, or at least not without writing more platform-specific code.

  • source
  • parent
  • [–] 5 points 6 months ago

    Another stupendous reason to gpl uutils so that the decades of experence of hundreds of system programmers can be leveraged in the rewrite.

  • source