Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Jan 2018 04:02:15 +0100
From:      Polytropon <freebsd@edvax.de>
To:        blubee blubeeme <gurenchan@gmail.com>
Cc:        FreeBSD <freebsd-questions@freebsd.org>
Subject:   Re: devd.conf and $USER
Message-ID:  <20180114040215.95ba04bc.freebsd@edvax.de>
In-Reply-To: <CALM2mEkaWXRLN1Hpuhkp=L3_ZZzkj0mKfWyjCRKU9OPXk3T22A@mail.gmail.com>
References:  <CALM2mEkaWXRLN1Hpuhkp=L3_ZZzkj0mKfWyjCRKU9OPXk3T22A@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 14 Jan 2018 09:30:47 +0800, blubee blubeeme wrote:
> Is there a way to pass the $USER env variable to an action initiated by
> devd?

What should this variable contain?

In case of FreeBSD (and UNIX in general), multi-user systems
allow that 0, 1, or 100+ users are logged in at the same time.
As devd handles dynamic device configuration at root level,
other user accounts active on the system don't matter.

However, it is easy to let devd branch to a custom script that
checks, for example, if a specific user is currently logged in,
and if it is, performs a user-specific action. In this case,
the corresponding logic needs to be implemented in that script,
as devd has no access to if a specific user is logged in at the
time a certain action needs to be performed (except, of course,
it is hardcoded into its configuration file, but in my opinion,
it's much easier and more convenient to put that logic into an
external script).

Many years ago, I needed exact that solution to make a crappy
printer work. Upon attaching the printer, the system checked if
the only user who was permitted to use that particular printer
was currently logged in, and if he was, started certain programs
first as root, then from that user account, created some specific
files in the user's directory, and finally, after some delay,
used xmessage to show the user a message that the printer was
now available.

As you can see, it was a _very_ crappy printer which needed all
this terrible stuff. ;-)



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180114040215.95ba04bc.freebsd>