----Messaggio originale----
Da: [email protected]
Data: 21/09/2010 10.12

A: "[email protected]"<[email protected]>
Cc: <busy...@busybox.
net>
Ogg: Re: R: Re: applet delgroup is incomplete (bb 1.17.2)

 Hi 
Tito!

>> Just one hint, take a cup of coffe and then look at the code:

>>              if (ENABLE_DELUSER
>>               && (!ENABLE_DELGROUP || 
>> applet_name
[3] == 'u')
>>              ) {
>>                      if (del_line_matching(argv, 
>> 
bb_path_passwd_file) < 0)
>>                              return EXIT_FAILURE;
>>                      if 
>> 
(ENABLE_FEATURE_SHADOWPASSWDS) {
>>                              del_line_matching(argv, 
>> 
bb_path_shadow_file);
>>                      }
>>              }
>>
>> then try to think about what 
you want to accomplish:

>And where should there be the code to delete 
a user of name NAME from a
>group of name GROUP?

>I do only see code 
to delete a line matching argv from the files passwd
>and shadow, that 
is to delete a user of name NAME from passwd or shadow.
>And if you 
continue that code listing you find code to delete a line
>matching a 
group named GROUP from the file group or gshadow ... but
>where is the 
code to delete the entry of the user NAME from the line of
>the group 
GROUP in file groups/gshadow, that is the code, that just
>removes the 
user name from the line in the group file (the reverse of
>addgroup 
NAME GROUP)???

>Sorry, but slowly getting frustrated ...

>Harald


Sorry, i needed to paste a few more lines code:

        if 
((ENABLE_FEATURE_DEL_USER_FROM_GROUP && argc != 3)
         || ENABLE_DELUSER
        
 || (ENABLE_DELGROUP && ENABLE_DESKTOP)
        ) {
                if (ENABLE_DELUSER
                 && 
(!ENABLE_DELGROUP || applet_name[3] == 'u')
                ) {
                        if 
(del_line_matching(argv, bb_path_passwd_file) < 0)
                                return 
EXIT_FAILURE;
                        if (ENABLE_FEATURE_SHADOWPASSWDS) {
                                
del_line_matching(argv, bb_path_shadow_file);
                        }
                } else if 
(ENABLE_DESKTOP && ENABLE_DELGROUP && getpwnam(argv[1]))
                        
bb_error_msg_and_die("can't remove primary group of user %s", argv[1]);


===> Here you error out because you try to remove the primary group of 
a user (?)

        }

===> here is the code to remove groups or users from 
groups 
           depending on the number of args passwed in argv

           1 arg = user  => remove user
           2 args = user + 
group => remove user from group

        if (del_line_matching(argv, 
bb_path_group_file) < 0)
                return EXIT_FAILURE;
        if 
(ENABLE_FEATURE_SHADOWPASSWDS) {
                del_line_matching(argv, 
bb_path_gshadow_file);
        }
        return EXIT_SUCCESS;

The real work is done 
in the update_passwd function in libbb which is called
by 
del_line_matching.
This used to work  unless some bug creeped in lately 
which I cannot test for at the moment.
The correct command line should 
be:

deluser USER GROUP

Ciao,
Tito



Risparmia con Tutto Incluso Light: telefono + adsl 8 mega a soli 19,95 € al 
mese per un anno!

SCONTO DI 120 EURO!

http://abbonati.tiscali.it/telefono-adsl/prodotti/tc/tuttoincluso_light/?WT.mc_id=01fw
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to