Bug 241519 - [patch] x11/sddm: use the login class capability database (/etc/login.conf, setusercontext)
Summary: [patch] x11/sddm: use the login class capability database (/etc/login.conf, s...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-kde (Team)
Keywords: buildisok
Depends on:
Reported: 2019-10-27 10:28 UTC by Martin Birgmeier
Modified: 2020-02-23 09:13 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (kde)

patch for x11/sddm to be applied in /usr/ports (4.21 KB, patch)
2019-10-27 10:28 UTC, Martin Birgmeier
no flags Details | Diff
patches for 0.18.1 (5.23 KB, application/gzip)
2020-02-07 16:02 UTC, Martin Birgmeier
no flags Details
new patch for Backend.cpp which should include ~/.login_conf (1.46 KB, text/plain)
2020-02-16 15:46 UTC, Martin Birgmeier
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Birgmeier 2019-10-27 10:28:48 UTC
Created attachment 208628 [details]
patch for x11/sddm to be applied in /usr/ports

The attached patch enables sddm to use the login class capability database in /etc/login.conf.

The handling of the environment is non-trivial, see the embedded comments.

-- Martin
Comment 1 Automation User 2019-11-11 02:03:50 UTC
Build info is available at https://gitlab.com/swills/freebsd-ports/pipelines/94962623
Comment 2 Gleb Popov freebsd_committer 2020-02-05 12:11:34 UTC
Hello Martin, thanks for the patch.

Looking at the code, I wonder if it takes into account ~/.login_conf file too?

Another question - what do you think about upstreaming this?
Comment 3 Martin Birgmeier 2020-02-05 19:57:05 UTC
Well, the code simply uses setusercontext and related functions in a way which makes them work with the restrictions given by QT5. I would assume that this function family conforms to login.conf(5) and therefore also reads .login_conf.

Regarding upstreaming I am not sure, this is rather specific to FreeBSD.

-- Martin
Comment 4 Gleb Popov freebsd_committer 2020-02-07 07:16:14 UTC
Can you rebase your patch onto 0.18.1 version of src/helper/UserSession.cpp, please? The code has changed a bit and I'm not 100% sure how to adapt your patch.

See https://github.com/sddm/sddm/blob/v0.18.1/src/helper/UserSession.cpp
Comment 5 Martin Birgmeier 2020-02-07 16:02:39 UTC
Created attachment 211450 [details]
patches for 0.18.1

I made a quick port of the patches (including the original ones from the FreeBSD port) to 0.18.1 but did not try them.

-- Martin
Comment 6 Martin Birgmeier 2020-02-07 16:19:59 UTC
One local change snuck in: I have MINIMUM_VT=2, but the original FreeBSD port uses 9. That should be reverted.

-- Martin
Comment 7 commit-hook freebsd_committer 2020-02-12 15:31:57 UTC
A commit references this bug:

Author: arrowd
Date: Wed Feb 12 15:31:28 UTC 2020
New revision: 525915
URL: https://svnweb.freebsd.org/changeset/ports/525915

  x11/sddm: Update to 0.18.1.

  Upstream does not provide a config file anymore. SDDM still reads
  /usr/local/etc/sddm.conf if it is present, but the intended way to configure
  it now is using /usr/local/etc/sddm.conf.d/ directory. See man sddm.conf(5) for

  Also include a patch to make SDDM take /etc/login.conf into account.

  PR:		241519
  Submitted by:	Martin Birgmeier <d8zNeCFG@aon.at> (login.conf patch)
  Differential Revision:	https://reviews.freebsd.org/D23579

Comment 8 Gleb Popov freebsd_committer 2020-02-12 15:32:56 UTC
Let's not close this yet, as I plan to give your patch more testing in my production environment.
Comment 9 Gleb Popov freebsd_committer 2020-02-13 12:17:32 UTC
Your patch indeed makes sddm use values from /etc/login.conf file, great job!

However, it still doesn't take ~/.login_conf files into account. Any chance you would implement that?
Comment 10 Martin Birgmeier 2020-02-13 15:15:49 UTC
Hi Gleb,

As I wrote in comment #3, I am not doing any parsing myself... it should all be done by setusercontext() et al. See https://www.freebsd.org/cgi/man.cgi?login.conf(5). Maybe it is necessary to configure the reading of ~/.login_conf specifically somewhere?

-- Martin
Comment 11 Gleb Popov freebsd_committer 2020-02-14 06:19:50 UTC
(In reply to Martin Birgmeier from comment #10)
Your code gets executed as root, so I think it is expected that it doesn't check users ~/.login_conf. Maybe it even does take /root/.login_conf into account (I didn't check that), but I want sddm to load .login_conf of **user being logged in**.

Since if you already took a look at the codebase, maybe you have an idea which part of code gets executed as user?
Comment 12 Martin Birgmeier 2020-02-14 16:17:48 UTC
How does your ~/.login_conf look like? Can you post it here?

Everything is done as root, but since a specific pw entry is referenced by the functions the correct config should be read.

It is interesting to read /usr/src/lib/libutil/login_class.c...

I don't know whether I'll come up with anything soon.

-- Martin
Comment 13 Gleb Popov freebsd_committer 2020-02-14 16:51:46 UTC
(In reply to Martin Birgmeier from comment #12)

% cat ~/.login_conf 
Comment 14 Martin Birgmeier 2020-02-16 15:46:51 UTC
Created attachment 211692 [details]
new patch for Backend.cpp which should include ~/.login_conf

Can you please try the new patch? It also corrects a memory leak.

Fortunately, K. Evans recently committed r357563 to the main FreeBSD sources... which taught me.

-- Martin
Comment 15 Gleb Popov freebsd_committer 2020-02-20 13:40:10 UTC
(In reply to Martin Birgmeier from comment #14)
Awesome, it works! I'll commit it shortly?

Are you still reluctant to upstream your patches? If yes, may I take your patch and upstream it myself?
Comment 16 commit-hook freebsd_committer 2020-02-20 13:50:24 UTC
A commit references this bug:

Author: arrowd
Date: Thu Feb 20 13:50:02 UTC 2020
New revision: 526571
URL: https://svnweb.freebsd.org/changeset/ports/526571

  x11/sddm: Enhance Backend.cpp patch to take into account not only /etc/login.conf
  but also ~/.login_conf file.

  PR:		241519
  Submitted by:	Martin Birgmeier <d8zNeCFG@aon.at>

Comment 17 Martin Birgmeier 2020-02-20 17:55:56 UTC
Hi Gleb,

I am happy to see that it works.

Of course you may upstream this!

Best regards,

Comment 18 Gleb Popov freebsd_committer 2020-02-21 06:28:41 UTC
Thanks for your work.
Comment 19 Martin Birgmeier 2020-02-21 07:55:40 UTC

It's a small return for all the work others have put in...

-- Martin
Comment 20 Serge Volkov 2020-02-22 19:43:35 UTC
Hi, All!

After upgrading to the version 0.18.1, I got a problem.

In the file /etc/rc.conf I have a variable sddm_lang="ru_RU". This variable is described in the file /usr/local/etc/rc.d/sddm. Previously, the SDDM interface was in Russian. Now the value of this variable does not affect anything. SDDM interface is now always in English.

Can any one help me?
Comment 21 Serge Volkov 2020-02-22 19:55:35 UTC
While writing the previous comment, I came up with a solution:

pw usermod sddm -L russian

Thus, I changed the SDDM interface language to Russian.
It may be necessary to change the information about the sddm_lang variable in the file /usr/local/etc/rc.d/sddm.
Comment 22 Gleb Popov freebsd_committer 2020-02-23 09:13:04 UTC
(In reply to Serge Volkov from comment #21)
Thanks for the report. Can you please open a new PR about this problem, and assign it to me, so it wouldn't get lost?