X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org MIME-Version: 1.0 In-Reply-To: <4FC76383.4030607@redhat.com> References: <4FC76383 DOT 4030607 AT redhat DOT com> Date: Thu, 31 May 2012 15:45:07 +0200 Message-ID: Subject: Re: [cron-config] Possible issue with administrators group ? From: AZ 9901 To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 2012/5/31 Eric Blake : > 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