1

I have always used text+console boot without graphic interface. This includes the login, that is also text only since I do some sync stuff at login time, specifically on tty1 where I have an autologin script, that executes the following command through the file /etc/systemd/system/getty@tty1.service.d/override.conf:

/usr/sbin/agetty --autologin <myusername> --noclear %I 38400 linux

I just upgraded to Fedora 36 (from 35), and the boot goes fine until the very last step. Instead of showing me a text login prompt, it shows a black screen with an underscore at the top left.

Why?

The command systemctl goes well except precisely for one red line:

● getty@tty1.service    loaded failed failed    Getty on tty1

In the logs, I can see an error:

agetty[4565]: /dev/tty1: "cannot get controlling tty: Operation not permitted"
agetty[4565]: setting terminal attributes failed: Input/output error

I can see this error in the console each time I try as root

 service getty@tty1.service start

I don't know what went wrong, but it seems the agetty command changed?

EDIT:

If I put the line:

ExecStart=-/usr/sbin/agetty --autologin <myusername> --noclear tty1 38400 linux

in the file /etc/systemd/system/getty@tty1.service.d/override.conf the autologin works. Yet, if I change to

ExecStart=-/home/<myusername>/bin/myautologinscript.sh

with the same line, it doesn't!!

3
  • 1
    Possibly needs to be the session leader. Try exec agetty... instead of agetty... in your script. Jun 22 at 6:38
  • Seeing the rest of systemctl show getty@tty1.service would probably help. Jun 22 at 6:43
  • Yes! Just adding the exec in front of hte agetty did it. But why? Why it wasn't necessary before? It would be nice if you write this as a solution and explain why it worked. Thanks! Jun 22 at 14:26

1 Answer 1

1

That cannot get controlling tty: Operation not permitted error by agetty is returned by agetty when the TIOCSCTTY ioctl() it makes so the terminal device becomes the controlling terminal of agetty's session fails.

It issues that ioctl() if the terminal currently doesn't control any session, or if it controls a session whose id is not agetty's pid.

From the tty_ioctl(2) man page:

TIOCSCTTY
      Argument: int arg

      Make the given terminal the controlling terminal of the  calling
      process.   The  calling process must be a session leader and not
      have a controlling terminal already.  For this case, arg  should
      be specified as zero.

      If  this  terminal is already the controlling terminal of a dif‐
      ferent session group, then the ioctl fails  with  EPERM,  unless
      the caller has the CAP_SYS_ADMIN capability and arg equals 1, in
      which case the terminal is stolen, and all processes that had it
      as controlling terminal lose it.

So, it won't work if agetty is not a session leader.

If you start a script that runs agetty in a child process instead of starting agetty directly, then the shell will be a session leader, and agetty will not.

Using exec agetty will run agetty in the same process as the shell (will replace the shell) and then agetty will be session leader.

If that worked in the previous version of Fedora with the same modus operandi, my guess would be that systemd had already made the terminal device the controlling terminal of the session, may by calling open() on it without the O_NOCTTY flag. But even then, having agetty not being the session leader sounds like a bad idea.

(I stroke that as in that case the controlled session would still not match agetty's pid, so it would still try to issue the TIOCSCTTY; I don't have another explanation for now).

1
  • Excellent! I would have never guessed this by myself. Thanks for the thorough explanation!! Jun 22 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.