News for hackers. Stuff that matters.
Re:I wish systemd logged information about the source of “tr... by TimWolla on Wednesday November 24, 2021 @03:30AM (#29327984)
A peer of mine was exiting their SSH sessions with 'exit'. One time apparently they already typed 'systemctl', probably in an attempt to check the status of a service, changed their mind and then later wanted to close the session using 'exit', actually executing 'systemctl exit'. This translated into a shutdown of the machine in question.

After being able to piece together what happened with the machine's logs and the bash history I recommended to simply exit all programs/sessions with Ctrl+D. It works almost everywhere and would have prevented this exact issue.

Re:I wish systemd logged information about the source of “tr... by lathiat on Wednesday November 24, 2021 @05:44AM (#29328714)
I can do one better for exit. The Solaris kernel debugger KDB can be used at runtime for inspecting some stats and also to change some global configurable variables.

For whatever reason if you type a variable/symbol it assigns it the value 0. If you type exit nothing happens immediately but as soon as the next process exits usually a few seconds to 10s of seconds later the entire system kernel panics on a null pointer de-reference.

Kernel paniced our production ZFS filer twice before I cottoned on. Newer releases special cased “exit” not to do that.

Re:I wish systemd logged information about the source of “tr... by heavenlyblue on Wednesday November 24, 2021 @05:49AM (#29328742)
That sounds like the most amazing UX I have ever encountered :)

For those familiar with Solaris, is there any reason they did it this way?

How can you possibly set the default behaviour of assigning any symbol a value of 0 by default?

Re:I wish systemd logged information about the source of “tr... by zaarn on Wednesday November 24, 2021 @12:58PM (#29332932)
Solaris is built on some idiosyncrasies (Speaking as someone who, as a Linux person, has to sysadmin Solaris systems).

For example, on our Solaris machines, after install, "reboot" does not do a clean reboot, it's a hard reset. If you want a clean reboot you need "init 6". Same story for "shutdown" and "init 5".

"killall" also kills all processes. Not the one you specified. Or more specifically it SIGKILLs all processes that have open files (ssh session and server go byebye). If you type "reboot" or "shutdown", this is in fact the binary that gets called do that.

Sadly, Solaris is also one of the few systems that support the NFSv4 ACLs (Linux supports NFSv4 but not the ACL Extension, TrueNAS has a patch for that).

Re:I wish systemd logged information about the source of “tr... by ibotty on Friday November 26, 2021 @02:21AM (#29348119)
Doesn't Ganesha support NFSv4 ACLs?
Re:I wish systemd logged information about the source of “tr... by zaarn on Friday November 26, 2021 @03:29AM (#29348389)
On Linux only for non-Filesystem backends (Ceph, Gluster, etc.)

The only fork of Ganesha that supports it on a proper filesystem is the TrueNAS fork and that only on their ZFS Fork that brings NFSv4 ACLs to Linux.

So really, no. You can't use NFSv4 ACLs with Ganesha on Linux outside of Forks or using scale-out data stores.

Re:I wish systemd logged information about the source of “tr... by gpderetta on Wednesday November 24, 2021 @06:59AM (#29329119)
That's of course due to the principle of maximal astonishment, a time honoured software design law.
Re:I wish systemd logged information about the source of “tr... by saagarjha on Wednesday November 24, 2021 @08:39AM (#29329845)
Hey, it’s better than what C does for its variables ;)
Re:I wish systemd logged information about the source of “tr... by ChuckMcM on Wednesday November 24, 2021 @11:47AM (#29331964)
because adb(1) did it that way.
Re:I wish systemd logged information about the source of “tr... by cyberpunk on Wednesday November 24, 2021 @12:26PM (#29332523)
Remember how on sparc machines if you turned off your laptop with the console cable connected it powers the servers down too?

That was a fun lesson…

Re:I wish systemd logged information about the source of “tr... by zorr on Wednesday November 24, 2021 @05:48AM (#29328737)
Years ago I had the habit of shutting down my laptop with "sudo shutdown -h now" at the end of the workday. Until one day I did that accidentally in a live SSH session.

Since then I always shut down my machine using the GUI and I have Tmux configured with different colors for SSH sessions.

Re:I wish systemd logged information about the source of “tr... by MattConfluence on Wednesday November 24, 2021 @08:01AM (#29329555)
One time I was using my laptop to remote desktop into a computer I was hundreds of km away from physically, I discovered that if I hit the power key on the laptop (yes, the laptop had a key on the keyboard for power, not a separate power button) while having the remote session window focused, it sent the signal over the wire and put the remote host to sleep instead. Whoops.

After that I looked up how to enable wake-on-lan and open up a port to be able to do that remotely.

Re:I wish systemd logged information about the source of “tr... by ahartmetz on Wednesday November 24, 2021 @09:03AM (#29330024)
I don't have the best experience with Wake-on-LAN, it stopped working after a BIOS update or something. So now my desktop is set to turn on when power comes back and it's connected to a WiFi switchable power socket. I bought one with the usual app/cloud rubbish and flashed Tasmota on it.
Re:I wish systemd logged information about the source of “tr... by iudqnolq on Thursday November 25, 2021 @02:56AM (#29339193)
I have some smart plugs I was planning to hack the network protocol of. I looked up Tasmota but I couldn't figure out how I could see if it would work with the random crap I bought on AliExpress and if so how to do it. Any advice?
Re:I wish systemd logged information about the source of “tr... by ahartmetz on Thursday November 25, 2021 @09:44AM (#29341730)
Well. I went the other way, I bought known compatible devices. In my case the inofficial name is "OBI socket 2", from the (German) OBI home improvement store. It's about 10€ a piece.

That said, if your device is based on some kind of Espressif ESP32 module, you might be able to find the right four pins on the circuit board and find or cobble together a configuration to talk to the I/O ports. Hardware required is a (usually USB) RS232 interface at 3.3 volts, some medium-thin cables, screwdriver, soldering iron, probably multimeter to check things. The firmware flashing and WiFi setup are fairly independent of the I/O port configuration, so you can flash something that can bring up the WiFi connection and web interface and experiment from there.

Re:I wish systemd logged information about the source of “tr... by thanatos519 on Wednesday November 24, 2021 @06:00AM (#29328796)
There's a package called molly-guard which can help with that.
Re:I wish systemd logged information about the source of “tr... by qwertox on Wednesday November 24, 2021 @10:33AM (#29330955)
It's a must on my systems. After I once rebooted the wrong server accidentally, I now force myself to go through the pain of confirming the hostname of the machine.

Also, it's possible to circumvent it when you have scripts that need to reboot the machine without interaction by issuing `reboot </dev/null` in the script.

Re:I wish systemd logged information about the source of “tr... by yencabulator on Wednesday November 24, 2021 @12:54PM (#29332868)
I've done the opposite, back in the day. I used server A's keyboard & monitor to SSH to admin server B. When I was done with the system upgrade on server B, I rebooted it with control-alt-del. Except I rebooted server A.
Re:I wish systemd logged information about the source of “tr... by ASalazarMX on Wednesday November 24, 2021 @01:10PM (#29333096)
Happened to me years ago. Fortunately that server had a power saving bug that most times rebooted it instead of powering it down.
Re:I wish systemd logged information about the source of “tr... by iforgotpassword on Wednesday November 24, 2021 @03:51AM (#29328107)
Almost entirely unrelated, but lately I worked with old photos that had missing, incomplete or wrong exif data. While trying to assess and automate fixing the collection via scripts, I used the command line utility "exif" a lot. You can't imagine how many times I typed "exit somefile.jpg" and flinched when the terminal window just closed. Guess I should just have created an alias but that's like resigning to your own stupidity. ;-)
Re:I wish systemd logged information about the source of “tr... by mike_hock on Wednesday November 24, 2021 @04:31AM (#29328319)
Also, spam Ctrl+C if you're gonna issue a new command after being AFK for a while.
Re:I wish systemd logged information about the source of “tr... by Denvercoder9 on Wednesday November 24, 2021 @03:36AM (#29328023)
I recommend not using root privileges unnecessarily. `systemctl status` and most other querying commands don't need root, while the dangerous things like `systemctl exit` do.
Re:I wish systemd logged information about the source of “tr... by usr1106 on Wednesday November 24, 2021 @03:41AM (#29328053)
Sure, but some systems do poweroff without being root. Has happened to me, don't remember the details. Maybe a polkit thing because users are supposed to shut down their own laptop?
Re:I wish systemd logged information about the source of “tr... by CraigJPerry on Wednesday November 24, 2021 @04:12AM (#29328226)
Yeah true, if the user is logged on via a physical tty or local X session (i.e. the policykit subject.local attribute == true) then in some distros they will get permission to shutdown or reboot.

They won’t have the permission if connected remotely though.

Re:I wish systemd logged information about the source of “tr... by TimWolla on Wednesday November 24, 2021 @03:58AM (#29328147)
I can't say what they had in mind when typing `systemctl`. Even they couldn't. Because of the delay in the shutdown to cleanly stop the services, they had already forgotten that they just exited a SSH session and thus the connection between the machine being dead and typing `exit` was not obvious.

Maybe it was `systemctl status`. Maybe it was intended to be a `reload` (which would require elevated privileges).

Re:I wish systemd logged information about the source of “tr... by AceJohnny2 on Wednesday November 24, 2021 @04:15AM (#29328245)
GP's point was more that you shouldn't be able to casually do "systemctl exit" in a standard shell session. All privileged operations should require a sudo. One might be tempted to just do a full "sudo shell" to perform all systemctl operations, but GP's point is that many of the "observation" actions don't require sudo in the first place!

In the end, the user being able to accidentally run "systemctl exit" may be indicative of a policy issue (ie don't allow root logins).

Re:I wish systemd logged information about the source of “tr... by iso1631 on Wednesday November 24, 2021 @07:10AM (#29329191)
All sudo actions on my machines are logged to a remote syslog server (and locally to /var/log/auth.log, which is rotated, compressed, and kept far longer than other logs). That certainly used to be standard. You can't log on as root, you have to log on as your own user and elevate to root (even if that's all you do with sudo), so there's a trail there.

This article suggests there are ways for programs to issue unaudited commands with elevated privileges to systemd.

"Systemd has a D-Bus interface that people can use, there's hardware events that may trigger a reboot, there are various programs that may decide to ask systemd to reboot the system, and under some circumstances systemd itself can decide that a particular, harmless looking process failure or 'systemctl' transaction actually will trigger a reboot through some weird chain of dependencies and systemd unit settings"

Complaining about systemd is as old as systemd, and borders on a religious war, a proxy towards "modern linux" and "old school unix" methods.

Re:I wish systemd logged information about the source of “tr... by Rapzid on Wednesday November 24, 2021 @04:23AM (#29328285)
But may not be. Maybe the policy is fine and changing it based on one machine shutdown is not worth the costs.
Re:I wish systemd logged information about the source of “tr... by usr1106 on Wednesday November 24, 2021 @03:38AM (#29328043)
I did not even know that systemctl exit exists. Tye man page says it's equivalent to poweroff (for the system manager not running in a container, i.e. the most common case).

Having 2 alternative commands for the same functionality is not a good design decision IMHO. But not the most central design decision for systemd.

Re:I wish systemd logged information about the source of “tr... by dharmab on Wednesday November 24, 2021 @02:46PM (#29334266)
there are already multiple commands for turning the computer off without systemd anyway
Re:I wish systemd logged information about the source of “tr... by genewitch on Wednesday November 24, 2021 @06:18AM (#29328871)
On average, systems are poo. The median modes around.

I prefer openRC, and I'll wave a flag or whatever but to each their own.

WinNT4 was goat.

Re:I wish systemd logged information about the source of “tr... by danesparza on Wednesday November 24, 2021 @08:12AM (#29329644)
... eyeing you suspiciously and backing away ...
Re:I wish systemd logged information about the source of “tr... by ungamed on Wednesday November 24, 2021 @07:54AM (#29329506)
I'll just get off your lawn.
Re:I wish systemd logged information about the source of “tr... by corney91 on Wednesday November 24, 2021 @10:50AM (#29331155)
Ctrl+D is great, but will still run a command if it's been typed out so I always Ctrl+C and then Ctrl+D.
Re:I wish systemd logged information about the source of “tr... by TimWolla on Wednesday November 24, 2021 @11:44AM (#29331928)
It does not for me. If the current command line is not completely empty it will not do anything (both with bash and fish). So if the terminal does not close after pressing Ctrl+D I will know that something is wrong and check more carefully.
Re:I wish systemd logged information about the source of “tr... by koheripbal on Wednesday November 24, 2021 @08:26AM (#29329745)
What's wrong with just closing the putty window?
Re:I wish systemd logged information about the source of “tr... by dec0dedab0de on Wednesday November 24, 2021 @12:31PM (#29332581)
Maybe they're not using a GUI ssh client, and wanted to return to their local shell.
Re:I wish systemd logged information about the source of “tr... by gruez on Wednesday November 24, 2021 @08:45AM (#29329880)
alt-f4 is slightly more efforts to do (requires hand contortions) comapred to writing out a word and typing enter. Also, control-D is easier.
Re:I wish systemd logged information about the source of “tr... by dharmab on Wednesday November 24, 2021 @02:48PM (#29334279)
ctrl+D/exit doesn't close the window in all cases. eg if you're sshed to a remote it returns you to local.