Re: [systemd-devel] How to set environment variable that is available for later services/shell

2017-03-14 Thread Zbigniew Jędrzejewski-Szmek
On Sat, Mar 11, 2017 at 06:14:17PM +0100, Sam Ravnborg wrote:
> Hi all.
> 
> How can we set environment variables so they are available for everyone?
> 
> 
> Background:
> 
> On an embedded target we use QT applications.
> 
> To start our QT application we need to set environment variables:
> 
> QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/event0 
> QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:mmsize=154x86:size=800x480 
> ...
> 
> 
> For now we use:
> [Service] 
>   
> EnvironmentFile=/etc/foo.conf
> 
> This has two drawbacks:
> 1) We cannot start the QT application from the
>command-line (unless we source the .conf file)
> 2) We need to use different .conf files (thus different
>.service files) depending on the HW configuration (display type/size)
> 
> So we are looking for a way to set the environment variables early
> such that they are available in the services launced later,
> and they are available in the shell.
> The actual system configuration will determine the values and
> it may differ from boot to boot.

There are a few different mechanisms, and which one is the best
fit depends on when the information about the content of those
variables is known and how widely it should be disseminated.

There are at least the following possibilities:
1. you could generate a file like /run/qtvars.conf from some service,
and make sure that this service is started at boot before any
relevant services (including user sessions), and import it there,
by doing EnvironmentFile=/run/qtvars.conf.

The advantage is that this gets run asynchronously during boot,
so it can wait for hardware to be detected.

2. (with systemd 233) you could also create a file like
/run/environment.d/60-qt.conf with similar contents,
and variables set therein would be available for services
started from systemd --user, and possibly some login environments.
This part is a work in progress, in particular ssh logins do not
inherit those variables. So this might be a solution in the
future, but probably not atm.

It sounds like doing 1. + adding '[ -f /run/qtvars.conf ] && . /run/qtvars.conf'
somewhere in /etc/profile.d might be your best option.

HTH,
Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to unset "uaccess" tag in udev rule?

2017-03-14 Thread Zbigniew Jędrzejewski-Szmek
On Sun, Mar 12, 2017 at 07:38:13PM +0100, Manuel Reimer wrote:
> Hello,
> 
> my distributor sets the following rule in /usr/lib/udev/rules.d:
> 
> KERNEL=="uinput", SUBSYSTEM=="misc", OPTIONS+="static_node=uinput",
> TAG+="uaccess"
> 
> I think this is not a good idea and that there is a good reason why
> users can't create uinput devices, so I want to get rid of that
> rule.
> 
> So far I did this by creating an empty file with the same name in
> /etc/udev/rules.d which works well, but for no reason the name was
> changed some time ago which overrides my empty file and reactivates
> the problematic rule.
That's the only way. Tags cannot be unset.

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Renaming interfaces with systemd.link

2017-03-14 Thread Chris Trobridge

On Fedora 25 I can rename a tap interface with a .link file in 
/etc/systemd/network but I cannot rename any Ethernet interfaces.

Reading around there are a few reports of issues for Debian and these seemed to 
relate the the use of initramfs (eg 
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=793374), which is also the 
case for Fedora.

I can rename the interfaces on another machine that boots without initramfs etc 
so perhaps this is it?

I cannot find any docs on how to use systemd.link when booting with initramfs.  
Is there any advice?  The Debian solution was to add the .link files to the 
initramfs but that feels heavy handed.

I now have the interfaces renamed by  creating 
"/etc/udev/rules.d/69-persistent-net.rules" with corresponding rules 
("70-persistent-net.rules" worked once and then got over written to nothing).

Cheers,
Chris
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel