public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* [cron-config] Possible issue with administrators group ?
@ 2012-05-29 16:17 AZ 9901
  2012-05-31 13:45 ` AZ 9901
  0 siblings, 1 reply; 6+ messages in thread
From: AZ 9901 @ 2012-05-29 16:17 UTC (permalink / raw)
  To: cygwin

Hello,

I am looking at the /bin/cron-config script.

Line 627, we can find :
elif net localgroup "${_admingroup}" | grep -Eiq "^${username}.?$"; then

Why .? at the end of the regexp ? "^${username}.?$"

We could have problems if for example we already have "user1" in
administrators group, and cron user is "user2".
"user2" would then not be added to the administrators group.

Do we have some buggy output from "net localgroup" on some Windows
versions to use .? at the end of the regexp ?

On my Windows XP, using grep -iq "^${username}$" works perfectly.
What about other Windows versions ?

Thank you very much !

Best regards,

Ben

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [cron-config] Possible issue with administrators group ?
  2012-05-29 16:17 [cron-config] Possible issue with administrators group ? AZ 9901
@ 2012-05-31 13:45 ` AZ 9901
  2012-05-31 16:18   ` Eric Blake
  0 siblings, 1 reply; 6+ messages in thread
From: AZ 9901 @ 2012-05-31 13:45 UTC (permalink / raw)
  To: cygwin

2012/5/29 AZ 9901 :
> Hello,
>
> I am looking at the /bin/cron-config script.
>
> Line 627, we can find :
> elif net localgroup "${_admingroup}" | grep -Eiq "^${username}.?$"; then
>
> Why .? at the end of the regexp ? "^${username}.?$"
>
> We could have problems if for example we already have "user1" in
> administrators group, and cron user is "user2".
> "user2" would then not be added to the administrators group.
>
> Do we have some buggy output from "net localgroup" on some Windows
> versions to use .? at the end of the regexp ?
>
> On my Windows XP, using grep -iq "^${username}$" works perfectly.
> What about other Windows versions ?
>
> Thank you very much !
>
> Best regards,
>
> Ben

Hello,

Any clue about this regexp ?

Thank you very much !

Best regards,

Ben

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [cron-config] Possible issue with administrators group ?
  2012-05-31 13:45 ` AZ 9901
@ 2012-05-31 16:18   ` Eric Blake
  2012-05-31 17:49     ` AZ 9901
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Blake @ 2012-05-31 16:18 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1042 bytes --]

On 05/31/2012 05:18 AM, AZ 9901 wrote:
> 2012/5/29 AZ 9901 :
>> Hello,
>>
>> I am looking at the /bin/cron-config script.
>>
>> Line 627, we can find :
>> elif net localgroup "${_admingroup}" | grep -Eiq "^${username}.?$"; then
>>
>> Why .? at the end of the regexp ? "^${username}.?$"

Because 'net' outputs in DOS mode, with carriage returns at the end.

>>
>> We could have problems if for example we already have "user1" in
>> administrators group, and cron user is "user2".
>> "user2" would then not be added to the administrators group.

Wouldn't that rather be "we could have problems if we already have
'user1', the output does not have carriage returns, and we are trying to
add 'user12'"?

> Any clue about this regexp ?

Since the trailing '.?' exists to strip carriage returns, would it be
any more robust to write this as:

net localgroup "${_admingroup}" | d2u | grep -Eiq "^${username}$"

-- 
Eric Blake   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 620 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [cron-config] Possible issue with administrators group ?
  2012-05-31 16:18   ` Eric Blake
@ 2012-05-31 17:49     ` AZ 9901
  2012-05-31 17:56       ` Dirk Sondermann
  0 siblings, 1 reply; 6+ messages in thread
From: AZ 9901 @ 2012-05-31 17:49 UTC (permalink / raw)
  To: cygwin

2012/5/31 Eric Blake <eblake@redhat.com>:
> On 05/31/2012 05:18 AM, AZ 9901 wrote:
>> 2012/5/29 AZ 9901 :
>>> Hello,
>>>
>>> I am looking at the /bin/cron-config script.
>>>
>>> Line 627, we can find :
>>> elif net localgroup "${_admingroup}" | grep -Eiq "^${username}.?$"; then
>>>
>>> Why .? at the end of the regexp ? "^${username}.?$"
>
> Because 'net' outputs in DOS mode, with carriage returns at the end.
>

OK, I was also thinking about this (talking about buggy output) but I
was not sure.
Strange that using grep -iq "^${username}$" works fine (well, I just
tested this on my XP).

Do Windows tools output in DOS mode "when they want" ?

>>>
>>> We could have problems if for example we already have "user1" in
>>> administrators group, and cron user is "user2".
>>> "user2" would then not be added to the administrators group.
>
> Wouldn't that rather be "we could have problems if we already have
> 'user1', the output does not have carriage returns, and we are trying to
> add 'user12'"?
>

Yes you're perfectly right, sorry for the mistake :-)

>> Any clue about this regexp ?
>
> Since the trailing '.?' exists to strip carriage returns, would it be
> any more robust to write this as:
>
> net localgroup "${_admingroup}" | d2u | grep -Eiq "^${username}$"
>

Yes I think so, or using sed 's/\r\n$/\n/'
Same effect, should work too.

Thank you !

Ben

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [cron-config] Possible issue with administrators group ?
  2012-05-31 17:49     ` AZ 9901
@ 2012-05-31 17:56       ` Dirk Sondermann
  2012-05-31 19:23         ` AZ 9901
  0 siblings, 1 reply; 6+ messages in thread
From: Dirk Sondermann @ 2012-05-31 17:56 UTC (permalink / raw)
  To: cygwin

On 31.05.2012 15:45, AZ 9901 wrote:
> 2012/5/31 Eric Blake <eblake@redhat.com>:
>> On 05/31/2012 05:18 AM, AZ 9901 wrote:
>>> 2012/5/29 AZ 9901 :
>>>> Hello,
>>>>
>>>> I am looking at the /bin/cron-config script.
>>>>
>>>> Line 627, we can find :
>>>> elif net localgroup "${_admingroup}" | grep -Eiq "^${username}.?$"; then
>>>>
>>>> Why .? at the end of the regexp ? "^${username}.?$"
>>
>> Because 'net' outputs in DOS mode, with carriage returns at the end.
> 
> OK, I was also thinking about this (talking about buggy output) but I
> was not sure.
> Strange that using grep -iq "^${username}$" works fine (well, I just
> tested this on my XP).

This works because the current version of grep (2.6.3-1) doesn't treat
its input as binary by default, but strips the carriage returns from
the output of net localgroup. So grep -iq "^${username}$" matches, but
grep --binary -iq "^${username}$" doesn't.

> Do Windows tools output in DOS mode "when they want" ?

No, od -c shows the \r\n endings in the output of net localgroup.

--Dirk

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [cron-config] Possible issue with administrators group ?
  2012-05-31 17:56       ` Dirk Sondermann
@ 2012-05-31 19:23         ` AZ 9901
  0 siblings, 0 replies; 6+ messages in thread
From: AZ 9901 @ 2012-05-31 19:23 UTC (permalink / raw)
  To: cygwin

2012/5/31 Dirk Sondermann :
> On 31.05.2012 15:45, AZ 9901 wrote:
>> 2012/5/31 Eric Blake <eblake@redhat.com>:
>>> On 05/31/2012 05:18 AM, AZ 9901 wrote:
>>>> 2012/5/29 AZ 9901 :
>>>>> Hello,
>>>>>
>>>>> I am looking at the /bin/cron-config script.
>>>>>
>>>>> Line 627, we can find :
>>>>> elif net localgroup "${_admingroup}" | grep -Eiq "^${username}.?$"; then
>>>>>
>>>>> Why .? at the end of the regexp ? "^${username}.?$"
>>>
>>> Because 'net' outputs in DOS mode, with carriage returns at the end.
>>
>> OK, I was also thinking about this (talking about buggy output) but I
>> was not sure.
>> Strange that using grep -iq "^${username}$" works fine (well, I just
>> tested this on my XP).
>
> This works because the current version of grep (2.6.3-1) doesn't treat
> its input as binary by default, but strips the carriage returns from
> the output of net localgroup. So grep -iq "^${username}$" matches, but
> grep --binary -iq "^${username}$" doesn't.
>
>> Do Windows tools output in DOS mode "when they want" ?
>
> No, od -c shows the \r\n endings in the output of net localgroup.
>

Thank you very much for this explanation, it makes sense !
So perhaps maintainer of cron package could update the regexp to avoid
the little possible issue :-)

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-05-31 18:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-29 16:17 [cron-config] Possible issue with administrators group ? AZ 9901
2012-05-31 13:45 ` AZ 9901
2012-05-31 16:18   ` Eric Blake
2012-05-31 17:49     ` AZ 9901
2012-05-31 17:56       ` Dirk Sondermann
2012-05-31 19:23         ` AZ 9901

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).