Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%n is not replaced with the user's ID #70

Closed
lahwaacz opened this issue Nov 3, 2019 · 7 comments
Closed

%n is not replaced with the user's ID #70

lahwaacz opened this issue Nov 3, 2019 · 7 comments

Comments

@lahwaacz
Copy link

lahwaacz commented Nov 3, 2019

When I set lock-file "/run/user/%n/fdm.lock", I get this error:

/run/user//fdm.lock: open: Permission denied

According to the manual, %n should be replaced with "The delivery user's uid." But set lock-file "%h/.cache/fdm.lock" works as expected, so "The delivery user's home directory." is expanded...

@josuah
Copy link

josuah commented Dec 14, 2019

I get a similar issue with %u, and also, %h works fine.

Running in verbose mode yields this:

options are: maximum-size=33554432, timeout=900, default-user="josuah", command-user="josuah", file-umask=077, queue-high=2, queue-low=1, strip-characters="\<>$%^&*|{}[]"'`;"
[...]
local: /var/mail//INBOX/cur: No such file or directory

So the username resolution went fine on fdm.c.

I suspect a missing update_tags() (from replace.c) somewhere.

I used the stdin fetch method. @lahwaacz what did you use?

@josuah
Copy link

josuah commented Dec 14, 2019

There is a call to replacepath in parse.y, and adding an update_tags() to it did the work for my case.

I'm giving you a patch...

@josuah
Copy link

josuah commented Dec 14, 2019

I can't upload a patch file (browser crashing), so here it goes:

diff -ru old/parse.y new/parse.y
--- old/parse.y	Sat Dec 14 16:37:06 2019
+++ new/parse.y	Sat Dec 14 16:40:14 2019
@@ -453,7 +453,10 @@
 replstrv: strv
 	  {
 		  struct replstr	rs;
+		  struct userdata	*ud;
 
+		  if ((ud = user_lookup(conf.def_user, conf.user_order)) != NULL)
+			  update_tags(&parse_tags, ud);
 		  rs.str = $1;
 		  $$ = replacestr(&rs, parse_tags, NULL, NULL);
 		  xfree($1);
@@ -462,7 +465,10 @@
 replpathv: strv
 	   {
 		  struct replpath	rp;
+		  struct userdata	*ud;
 
+		  if ((ud = user_lookup(conf.def_user, conf.user_order)) != NULL)
+			  update_tags(&parse_tags, ud);
 		  rp.str = $1;
 		  $$ = replacepath(&rp, parse_tags, NULL, NULL, conf.user_home);
 		  xfree($1);

To apply it:

git clone https://github.com/nicm/fdm/
cd fdm
patch -p 1
<paste the patch and Ctrl+D>

And rebuild.

@lahwaacz: does it work for you?
@nicm: does it look good, do you prefer a pull request?

@nicm
Copy link
Owner

nicm commented Dec 17, 2019

Applied now, thanks!

@nicm nicm closed this as completed Dec 17, 2019
@vesath
Copy link

vesath commented Dec 28, 2019

The above patch makes fdm segfault when conf.def_user is NULL. I'm happy to define default-user in my fdm.conf but did not think this was a requirement. For reference, here's the backtrace of said segfault:

#0  0x00007ffff7949bcd in _nss_files_getpwnam_r () from /usr/lib/libnss_files.so.2
#1  0x00007ffff7a88a13 in getpwnam_r@@GLIBC_2.2.5 () from /usr/lib/libc.so.6
#2  0x00007ffff7a882fc in getpwnam () from /usr/lib/libc.so.6
#3  0x000055555556f990 in passwd_lookup (user=0x0) at lookup-passwd.c:36
#4  0x000055555556fac8 in user_lookup (user=0x0, order=0x555555598510) at lookup.c:35
#5  0x000055555557b08a in yyparse () at parse.y:461
#6  0x000055555557e087 in parse_conf (path=<optimized out>, macros=0x7fffffffbcb0) at parse.y:83
#7  0x000055555555b3c4 in main (argc=1, argv=0x7fffffffe3a0) at fdm.c:459

Cheers.

@nicm
Copy link
Owner

nicm commented Dec 28, 2019 via email

@vesath
Copy link

vesath commented Dec 28, 2019

Thanks. Master works perfectly now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants