Re: [matth...@openbsd.org: Re: xlock don't take my password anymore]

2022-08-29 Thread Matthieu Herrb
On Mon, Aug 29, 2022 at 09:08:26AM +0200, Greg Steuck wrote:
> Greg Steuck  writes:
> 
> Matthieu> +   authok = priv_pw_check(user, style, pass);
> 
> I suspect your original patch may have swapped the arguments. The
> password should go before style.

Oops you're right thanks.


> 
> What do you thing about this patch (tested locally, but I don't have
> style):

Works for me. I also cannot check style easyly (otherwise I would
probably have caught the mistake, but I've check with
and without : in the password).

> 
> diff --git a/app/xlockmore/xlock/passwd.c b/app/xlockmore/xlock/passwd.c
> index 914db414f..23ba9043e 100644
> --- a/app/xlockmore/xlock/passwd.c
> +++ b/app/xlockmore/xlock/passwd.c
> @@ -1278,17 +1278,15 @@ checkPasswd(char *buffer)
>  
>  #ifdef USE_PRIVSEP
>   char*pass;
> - char*style;
>  
>   /* buffer can be in the form style:pass */
>   if ((pass = strchr(buffer, ':')) != NULL) {
> - *pass++ = '\0';
> - style = buffer;
> - } else {
> - pass = buffer;
> - style = NULL;
> + *pass++ = '\0';
> + if (priv_pw_check(user, pass, buffer))
> + return True;
> + *--pass = ':';
>   }
> - return priv_pw_check(user, pass, style);
> + return priv_pw_check(user, buffer, NULL);
>  #elif defined(BSD_AUTH)
>   char   *pass;
>   char   *style;
> -- 
> 2.37.2
> 

-- 
Matthieu Herrb



Re: [matth...@openbsd.org: Re: xlock don't take my password anymore]

2022-08-29 Thread Greg Steuck
Greg Steuck  writes:

Matthieu> + authok = priv_pw_check(user, style, pass);

I suspect your original patch may have swapped the arguments. The
password should go before style.

What do you thing about this patch (tested locally, but I don't have style):

diff --git a/app/xlockmore/xlock/passwd.c b/app/xlockmore/xlock/passwd.c
index 914db414f..23ba9043e 100644
--- a/app/xlockmore/xlock/passwd.c
+++ b/app/xlockmore/xlock/passwd.c
@@ -1278,17 +1278,15 @@ checkPasswd(char *buffer)
 
 #ifdef USE_PRIVSEP
char*pass;
-   char*style;
 
/* buffer can be in the form style:pass */
if ((pass = strchr(buffer, ':')) != NULL) {
-   *pass++ = '\0';
-   style = buffer;
-   } else {
-   pass = buffer;
-   style = NULL;
+   *pass++ = '\0';
+   if (priv_pw_check(user, pass, buffer))
+   return True;
+   *--pass = ':';
}
-   return priv_pw_check(user, pass, style);
+   return priv_pw_check(user, buffer, NULL);
 #elif defined(BSD_AUTH)
char   *pass;
char   *style;
-- 
2.37.2



Re: [matth...@openbsd.org: Re: xlock don't take my password anymore]

2022-08-26 Thread Greg Steuck
Hi Matthieu,

I'd be inclined to go with a return in the middle and avoid some extra
variables, what do you think about the following (entirely eye-ball tested)?

char*pass;

/* buffer can be in the form style:pass */
if ((pass = strchr(buffer, ':')) != NULL) {
*pass++ = '\0';
   if (priv_pw_check(user, buffer, pass))
  return 1; /* or whatever success indicator */
   *--pass = ':';
 }
 return priv_pw_check(user, buffer, NULL);

Thanks
Greg



[matth...@openbsd.org: Re: xlock don't take my password anymore]

2022-08-26 Thread Matthieu Herrb
ok ?

(although I didn't get an answer from Jean-Michel yet, I'm quite sure
the issue is real and the fix correct).

- Forwarded message from Matthieu Herrb  -

Date: Tue, 23 Aug 2022 11:08:28 +0200
From: Matthieu Herrb 
To: BESSOT Jean-Michel 
Cc: b...@openbsd.org
Subject: Re: xlock don't take my password anymore

On Sun, Aug 14, 2022 at 01:05:49PM +0200, BESSOT Jean-Michel wrote:
> Hello
> 
> Xlock do not take my password since my last snapshot update (well there is
> time since the one before).
> 
> I use a bépo keyboard so kdb is set with fr dvorak
> 

Hi,

can you try the patch below (already tested by Denis, who provided a
hint on the issue) ?

(get the xenocara tree, apply in app/xlockmore using patch(1) and
rebuild xlockmore by running the following commands in
/usr/xenocara/app/xlockmore :

doas make -f Makefile.bsd-wrapper obj
doas make -f Makefile.bsd-wrapper build

Index: xlock/passwd.c
===
RCS file: /cvs/OpenBSD/xenocara/app/xlockmore/xlock/passwd.c,v
retrieving revision 1.3
diff -u -r1.3 passwd.c
--- xlock/passwd.c  26 Jun 2022 14:09:51 -  1.3
+++ xlock/passwd.c  22 Aug 2022 21:35:49 -
@@ -1279,16 +1279,19 @@
 #ifdef USE_PRIVSEP
char*pass;
char*style;
+   int  authok;
 
/* buffer can be in the form style:pass */
if ((pass = strchr(buffer, ':')) != NULL) {
*pass++ = '\0';
style = buffer;
-   } else {
-   pass = buffer;
-   style = NULL;
-   }
-   return priv_pw_check(user, pass, style);
+   authok = priv_pw_check(user, style, pass);
+   *--pass = ':';
+   } else 
+   authok = 0;
+   pass = buffer;
+   style = NULL;
+   return (authok || priv_pw_check(user, pass, style));
 #elif defined(BSD_AUTH)
char   *pass;
char   *style;


-- 
Matthieu Herrb


- End forwarded message -

-- 
Matthieu Herrb