jlm-blog
~jlm

31-Mar-2020

TIL: gshadow has user lists

Filed under: linux — jlm @ 21:37

While I was chatting (well, rapid-fire emailing) with a friend who works as a system administrator, he dropped a bit of Linux trivia on me: It’s not just /etc/group which has user lists, the /etc/gshadow file also has user lists — more than /etc/group does, even! After the crypted password is a list of group administrators, then a list of shadow members. The former have the ability to change the group’s password as well as its membership using the gpasswd command. The latter can make the group be their primary group by calling newgrp without needing a password. (See man gshadow.)

5-Oct-2017

Tutorial for building .so files

Filed under: linux, programming — jlm @ 18:34

Exactly how one goes about building .so files* isn’t widely understood, and the documentation on it is overcomplicated IMHO. So, I figure the web needs a tutorial demonstrating how to build an extremely simple .so file. Et voilà, here’s a step by step guide for building a .so file on Linux or a similarly flavored Unix using a GNU-compatible toolchain.

We’re going to make two .o files, “call_me.o” and “die.o”, and combine them into a single “call_me_and_die” shared library. Making a library is very much like making an executable, just with some tweaks to the build commands and some extra steps at the end. To make our “call_me_and_die” library, we start the way we would with a “call_me_and_die” executable: writing a .h file for the common function signatures. File so_tut.h:

extern void call_me(void);
extern void die_die_die(void);

(more…)

11-Sep-2017

EBUSY: Another decade, and still sucking

Filed under: general, linux, programming — jlm @ 12:40

Today’s xkcd riffs a common frustration about busy files: programs that can’t do their intended operations on them rarely (if ever) specify the file that’s busy or tell the user which programs are using the file — and without that knowledge, the user can’t fix the problem.

There are tools that can help you discover those things, as I describe using ten years ago, but I’d already been running into EBUSY problems for ten years by then, and the old guard before me for another ten years beyond that. Why haven’t things improved?

Sometimes file_operation(filename) fails — hey, this happens, busy files are a thing, ain’t nothing your program can do about that. But report to the user that file_operation on filename failed for reason strerror(errno)! Not reporting the filename is just sloppy programming.

It’s not like the tools have gotten any better. What, you think it’s acceptable to make the user trace your program, looking through a haystack of every system call to find the needle which is the program’s critical failure? Is that work you’re putting on the user’s shoulders less than sticking the filename in the error message? This has sucked for two generations now. Please help making it suck less.

20-Nov-2012

How not to do automatic updates

Filed under: linux — jlm @ 10:47

Today’s attempt at upgrading packages produced this:

Reading package lists... Error!
E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/apt/lists/extras.ubuntu.com_ubuntu_dists_precise_main_i18n_Translation-en
E: The package lists or status file could not be parsed or opened.

The contents of that file?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">  
   <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
   <META HTTP-EQUIV="refresh" CONTENT="0;url=https://login.wifiportal.co.nz">
   <TITLE>Welcome to FIVO Hotspot, Product of Natcom LTD NZ</TITLE>
</HEAD>
<BODY>

</BODY>
</HTML>

I don’t have unattended upgrades enabled on my Ubuntu laptop. Nevertheless, there’s something which goes around and replaces files in /var/lib/apt with whatever junk it gets from whatever network it happens to be connected to at random times. Can I be the only person who thinks this is a Really Bad Idea?

19-Jun-2012

Stopping laptop suspend on Ubuntu Linux

Filed under: linux — jlm @ 21:15

The default configuration for Ubuntu is to suspend the laptop any and every time the lid is closed, regardless of whether it’s on AC power or using an external display and keyboard, which is pretty annoying but up until Oneiric the setting wasn’t too difficult to discover and override. With Oneiric, Ubuntu reset the suspend options during the upgrade and removed it from GUI accessibility (Options are bad! Everyone uses computers the same way! No one uses an external KVM with a laptop! Gag.), but 5 seconds of web search reveals how to set it with the command line: gsettings set org.gnome.settings-daemon.plugins.power lid-close-ac-action nothing

Except one problem. This only affects the PM settings if you’re logged in to the primary X console. I also want to be able to use my laptop headless. What to do when not logged in was set under “system” (as opposed to “user”) options in the no-longer-available GUI, but no references I found told how to set it from the command line. This is done by running gsettings set as a system user unsurprisingly, but unfortunately, gsettings doesn’t work from sudo or su, because gsettings wants to start up dbus because … I don’t know why. And it won’t run without X, and gsettings won’t run without dbus. So, how do you run something non-graphical with dbus access? That turns out to be with the dbus-launch command, which can figure out it’s not in X unlike whatever gsettings is doing to start dbus, so what we want is sudo dbus-launch gsettings set org.gnome.settings-daemon.plugins.power lid-close-ac-action nothing

Ha ha, no. That changes the setting for the root user, but the laptop still suspends. This turns out to be because the settings used when awaiting login aren’t root’s, but gdm’s. So that means to stop the suspending, we do sudo -u gdm dbus-launch gsettings set org.gnome.settings-daemon.plugins.power lid-close-ac-action nothing

Ha ha, no. See, the documentation on whose settings are used is wrong. It’s not gdm’s settings that are used at all. (That’s whose was used up to Natty.) If you look at your passwd file, you’ll see there’s a new display-manager user in addition to gdm now: lightdm. What the docs don’t say is that it’s that user whose settings are used now. So, no more teasing, this is the command which keeps your laptop powered on: sudo -u lightdm dbus-launch gsettings set org.gnome.settings-daemon.plugins.power lid-close-ac-action nothing

30-Nov-2011

Recommended software: disper

Filed under: linux — jlm @ 12:23

One of the common use cases for laptops is to plug into an external display at a docking station or with a projector, and unplug and use the internal display, then plug into another external display, then later back to the internal display, and keep on cycling like this. Unfortunately, Linux distributions haven’t supported switching displays very easily.

Enter disper to save the day. This is a command-line (and so easily scriptable) tool to switch the display in use. For example, to make only the internal display active, run disper -s. For only the external display, disper -S. And to toggle between them, disper --cycle-stages='-s:-S' -C. So when I want to bind one of the special laptop function keys to alternate between external-display-active-only and internal-display-active-only in Gnome, I run gnome-keybinding-properties, add a custom shortcut to run disper --cycle-stages=-s:-S -C, and bind that to XF86LaunchA. Voilà, with one keypress I can switch between the laptop’s screen and the projector. Other flags to disper let you activate both displays, etc.

18-Jun-2011

Linux distribution switch, 2011 edition

Filed under: linux — jlm @ 23:15

I switched to OpenSuSE tonight.
PCLinuxOS had been grating on me for the last few months, since they decided to drop most of their man pages in favor of entering “man foo” into Google. But after an ordinary update, tonight I discovered that the new kernel hung on boot. To my distress, GRUB didn’t list any previous kernels when I intercepted its autoboot. After trying and failing to get grub to show me any files on the filesystem so I could select another kernel from /boot to boot from (why is this so hard?), I booted from a rescue disk… and discovered that there was only one kernel version in /boot, PCLinuxOS had been deleting the previous versions. This bad practice dismayed me, it’s standard for distributions to keep the previous one or two kernels around, in case of a case like this, where a kernel that doesn’t boot on someone’s hardware get pushed.
I’d been meaning to try out SuSE again for a while, and this pushed me over. I backed up my disk and did a clean install.
We’ll see how the new distribution goes.

10-Jan-2011

Got an Eee? Forget Easy Peasy

Filed under: linux — jlm @ 00:56

So, I just upgraded Easy Peasy on my Eee. And surprise, surprise, it broke WiFi again.
Fortunately, there’s a user-contributed fix available, like the other times this has happened!
Unfortunately, the maintainers aren’t adopting it, also just like the other times!

This is a distribution targeting one specific line of netbooks, and in every version of it, WiFi doesn’t work. Scrapheap time for Easy Peasy.

4-Oct-2009

Floating point exception after upgrading libgcc1 (PCLinuxOS) (fix)

Filed under: linux — jlm @ 22:34

I was just upgrading my packages, like I do every so often. This time ’round the package update list was:
bash bluez-utils dkms-ndiswrapper e2fsprogs grub grub-doc libgcc1 losetup
ndiswrapper pclinuxos-release update-notifier

Went ahead, it installed cleanly, but afterwards I was getting floating point exceptions from some programs. ldd shows libgcc_s as a likely culprit, what with the just-done upgrade including
libgcc1-4.4.1-1pclos2010.i586 ############################## [100%]

Play around with apt-get, to see if I can get an older version from apt — uh oh, apt-get says floating point exception when invoked. Grab a Mandriva RPM from the net, give it to rpm — rpm dies with floating point exception. No problem, I’ll install the files by hand, just extract them with rpm2cpio — which hits a floating point exception.

Finally, I wise up, scp libgcc1_s.so.1 from a Debian system.
cd /lib
sudo mkdir brokengcc1
sudo mv libgcc_s* brokengcc1
sudo cp /tmp/libgcc_s.so.1 .
sudo chmod 0755 libgcc_s.so.1

And everything is working again, at least enough to tide me over until PCLinuxOS fixes the libgcc1 package. If anyone else is stuck by this, the libgcc I used is here.

30-Aug-2009

Upgrade season

Filed under: linux — jlm @ 12:44

So, I’ve done a bunch of upgrades to my systems lately. After Ubuntu broke my X again somehow going from Intrepid to Jaunty (this time not recognizing my input devices), I switched over to PCLinuxOS (2009.2). I’m still getting used to it. The apt-rpm stuff seems to work well, and stuff I had to fight to get going in Ubuntu, like flashplayer and xmms, just work. Java actually runs, and there’s a desktop link to the magic for getting OpenOffice working. On the other hand, the package repository feels a lot smaller, not having programs I’ve long used like calc, ccrypt, dict, and procmeter.

WordPress had a series of security vulnerabilities, so I’ve updated to the latest version. As a plus, it finally knows about the system’s timezone database, so is no longer the only program you have to adjust an hour whenever daylight savings starts or stops. The WordPress upgrade process is getting easier, manual editing of the mysql db no longer needed. Hopefully one of these days they’ll simplify it down to “apt-get upgrade”-level, and it can keep itself up to date the same way everything else does.

I also upgraded the Easy Peasy (formerly known as Ubuntu Eee) install on my EeePC. I can’t speak about the install problems I noted in my last post on Easy Peasy, but most of the runtime problems seem to have been fixed — except the inability to turn the WiFi on! Another user put together a fix in February, but unincorporated by the maintainers. I find this bug just as staggering to find today as I did last December. How can this still not work out of the box after all this time?

Powered by WordPress