10 ms·
Memory corruption... Someone would ask this sooner or later, so.. why is this written in C, really?
by Filligree 9y ago
Memory corruption...
Someone would ask this sooner or later, so.. why is this written in C, really?
- tormeh 9y agoBecause proper, hardcore programmers never make memory management mistakes and memory management is not that big of a problem, obviously. /s
- 128312983891 9y agoAnd non-hardcore programmers never write anything at all but evangelize other languages instead. /s
- fao_ 9y agoI mean, calling systemd programmers 'proper', 'hardcore', or even 'responsible' is a real stretch [http://suckless.org/sucks/systemd http://suckless.org/sucks/systemd]
- setq 9y agoIndeed. Merely "loud" programmers with corporate backing.
- revelation 9y agoThat is not what springs to mind, more "why the fuck are you reimplementing DNS in init". Like, this stuff was built tens of years ago and that code is crappy too but we have pretty much got rid of the most obvious security issues. Nobody wants to relive history so you can finally implement a broken DNS client.
- s_kilk 9y ago> "why the fuck are you reimplementing DNS in init" Because systemd
- vertex-four 9y agosystemd is not "just" init, it's a suite of various tools, most of which (including systemd-resolved) don't run as PID 1. It's a monolith by the fact that this project decided to take over a variety of normal system daemons and make it as difficult as possible to use many of them without using the rest - it's not a monolith in the sense of everything running in the same process. I believe systemd-resolved, however, is one of those components that is entirely optional, and which nothing explicitly depends on... which makes it weird that Ubuntu chose to use it by default.
- icebraining 9y agoUbuntu already had a resolver installed by default on desktops (dnsmasq). They decided to switch because: we picked "resolved" as that is small and lightweight, already present (part of the systemd package), does not require D-Bus (unlike dnsmasq), supports DNSSEC, provides transparent fallback to contacting the real DNS servers directly (in case anything goes wrong with the local resolver), and avoids the first issue above that /etc/resolv.conf always shows 127.0.0.1.
- digi_owl 9y agoDo not require dbus?! https://www.freedesktop.org/wiki/Software/systemd/resolved/ https://www.freedesktop.org/wiki/Software/systemd/resolved/
- icebraining 9y agoAre you confusing "can use" with "requires"?
- digi_owl 9y agoI suspect any alternative is a fall back that cause as much troubles as it "solves". After all, the principle devs of systemd are all very much in love with dbus (bloody thing require a copy to be started by initramfs even).
- 9y ago
- FridgeSeal 9y agoHow plausible is it that someone/some group could rewrite/update this to be written in Rust? (Which would presumably solve a lot of the memory corruption issues if I understand Rust's memory safety correctly?).
- teamhappy 9y agoNot plausible at all. * Rewriting a codebase is much harder than it seems * systemd is pretty big (376,726 LOC according to Open Hub) which makes it even harder to rewrite * All maintainers and contributors are C programmers * Distros don't want their codebase to be made up of many different languages
- rndgermandude 9y ago* You can just rewrite systemd-resolved (and similar networked services), not the entire systemd, for a start. E.g. Firefox, which has even more LOC, started rewriting a ton of stuff in javascript and now rust (e.g. mp4 parsers was the first rust code in Firefox IIRC) * If your project lacks people with the required skill set, then reach out to programmers who got what you need and educate yourself. * Distro codebases are not just C since forever, they are a mix of all kinds of stuff, in particular but not limited to C, C++, perl, shell, python.
- teh_klev 9y ago> Distro codebases are not just C since forever, they are a mix of all kinds of stuff Indeed....I was surprised to discover OCaml used in Citrix XenServer when spelunking the codebase.
- wott 9y ago> systemd is pretty big (376,726 LOC according to Open Hub) which makes it even harder to rewrite That's about twice as much as the Linux kernel when I started using a Linux distribution, I believe...
- 9y ago
- notalaser 9y ago> Someone would ask this sooner or later, so.. why is this written in C, really? When systemd was started, Rust barely had a working compiler and go had been announced for about one year.
- lmm 9y agoSure, but Ada was a first-class language in GCC, many distributions shipped OCaml code...
- notalaser 9y agoDo you think (as in bet-your-company's-profits-on-it believe) that Ada will still be a first-class language in GCC ten years from now (the standard product lifecycle for RHEL), and that you'll be able to staff the project and build a community throughout that period?
- lmm 9y agoIf I had to choose between betting my company's profits on Ada or C, I'd choose Ada (though I think there are better choices today). Limited tools and a need to train developers are easier to deal with than random crashes and security vulnerabilities.
- notalaser 9y agoBut it's not "just" limited tools and a need to train developers. A language having a small community results in a lack of library and collaboration; you end up dealing with tool vendors who barely manage to keep themselves afloat, let alone invest in development, with long unmaintained libraries, with months, sometimes years passing between when a new architecture or OS is available and when the compiler and the libraries you use get updated. It's not too different from how things are in Common Lisp land, a language (and a land...) that I'm pretty familiar with. It's a great, probably the best language. There are a few success stories, but truth is, in 2017, most large-scale, non-hobby projects are failures.
- 9y ago
- digi_owl 9y agoNah, more like why do systemd include anything to do with DNS at all. The shoggoth keep sprouting pseudopods as devs gets bored and think they can reimplement a time tested daemon in a weekend.
- pawadu 9y agoGood to know I am not the only one thinking this way...
- jameskegel 9y ago>The shoggoth keep sprouting pseudopods You're spot on.
- Asooka 9y agoWe should just start submitting patches that more or less copy-paste the code of the current best solution to the problem over the systemd implementation.
- setq 9y agoThere's a good implementation of systemd here: https://github.com/bluerise/openbsd/tree/master/sbin/init https://github.com/bluerise/openbsd/tree/master/sbin/init
- qb45 9y agoHow else would you get DNS responses in XML over DBus? ;)
- deno 9y agoDBus only uses XML for its introspection interface. There’s really no reason why you couldn’t switch it to anything else like tomorrow. Specifically, DBus does not use XML for any message passing or data serialization. It uses its custom binary on-wire format. Also to consume or provide DBus services you do not need to interact with any XML whatsoever (except maybe for Polkit but that’s not DBus).
- a3n 9y agoI imagine because the people who wrote it were C programmers. Did any Ada/DNS or other $LANG/DNS people step up?
- Koshkin 9y agoSame can be asked about Linux, the kernel.
- Someone1234 9y agoLinux was written in 1991. Systemd was started in 2010. The further you go back in time the less relevant the question is. And arguably any projects in the future written in C instead of a safer language really need to justify that choice if they sit on a security boundary. C will be around for another hundred years or more. But hopefully new software looks beyond C giving that programmers seemingly cannot write and maintain secure software in it.
- pjmlp 9y ago> The further you go back in time the less relevant the question is. As Hoare so elegantly described at his Turing award speech, regarding Algol compilers, done in 1981: "Many years later we asked our customers whether they wished us to provide an option to switch off these checks in the interests of efficiency on production runs. Unanimously, they urged us not to--they already knew how frequently subscript errors occur on production runs where failure to detect them could be disastrous. I note with fear and horror that even in 1980, language designers and users have not learned this lesson. In any respectable branch of engineering, failure to observe such elementary precautions would have long been against the law." Algol dialects like ESPOL and its successor NEWP where used for systems programming the Burroughs B5500 in 1961, 10 years before C was born, nowadays still sold by Unisys as ClearPath MCP.
- Koshkin 9y agoWell, I guess, this has got to be said: security should never be a concern for application software developers. This may or may not apply to things like systemd which live somewhere on the boundary between what would be pure "system" and "application" programs, but it is undeniably true that application program code, such as that of a document editor or a calculator, should be solely concerned with the application side of things, i.e. correctness and efficient implementation of what is otherwise known as "business logic", and security is usually not one of them - contrary to a very common, but mistaken, perception. It is the "system" component of the execution environment that should focus on what it has been designed for in the first place. Therefore, ideally, it should not matter what programming language is used to write application software - whether it is C, Rust, Prolog, or SQL; it does sound ironic, though, that the most demanding pieces of a system - demanding in terms of reliability and security - are usually written in an "unsafe" language.
- 4ydx 9y agoIn a word? Arrogance. LOC in c required to create systemd and all of its unnecessary processes is astounding.