Commit Graph

99 Commits

Author SHA1 Message Date
Denys Vlasenko
5de450237c libpwdgrp: do not require that /etc/passwd entries have nonempty home and shell
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-12 04:06:18 +02:00
Tito Ragusa
cb6a112f09 libpwdgrp: fix thinko in getpwnam
function                                             old     new   delta
parse_file                                             -      64     +64
getXXnam_r                                           162     138     -24
getXXnam                                              90      50     -40
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 64/-64)              Total: 0 bytes

Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-19 22:03:56 +01:00
Denys Vlasenko
23cfaab47d libpwdgrp: use getpwent() instead of getpwent_r()
function                                             old     new   delta
massage_data_for_non_r_func                            -      90     +90
bb_internal_getpwent                                   -      69     +69
getXXnam_r                                            94     162     +68
fill_bounds                                          131     128      -3
deluser_main                                         355     310     -45
complete_username                                    123      78     -45
getXXnam                                             163      90     -73
massage_data_for_r_func                              103       -    -103
bb_internal_getpwent_r                               121       -    -121
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 1/5 up/down: 227/-407)         Total: -163 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-07 21:21:02 +01:00
Tito Ragusa
e5cae08f12 libpwdgrp: line counting in error meesages is broken, remove it
Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-06 01:22:36 +01:00
Denys Vlasenko
c5d4a04e45 libpwdgrp: fixes suggested by Tito, comment tweaks
function                                             old     new   delta
bb_internal_getpwent_r                               100     121     +21
parse_common                                         202     203      +1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-05 15:09:04 +01:00
Denys Vlasenko
db4d1051ca libpwdgrp: another code shrink
function                                             old     new   delta
massage_data_for_r_func                                -     110    +110
bb_internal_getpwent_r                               173     100     -73
getXXnam_r                                           176      95     -81
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 110/-154)          Total: -44 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-04 02:34:52 +01:00
Denys Vlasenko
5acf1346b4 libpwdgrp: code shrink
function                                             old     new   delta
parse_common                                         206     205      -1
getgrouplist_internal                                229     225      -4
bb_internal_getpwent_r                               182     173      -9
getXXnam                                             232     222     -10
getXXnam_r                                           216     176     -40
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/5 up/down: 0/-64)             Total: -64 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-04 02:02:39 +01:00
Denys Vlasenko
12fc869560 libpwdgrp: getgrXXX: empty string is not a member name, do not store it
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-03 21:16:18 +01:00
Denys Vlasenko
402451aa19 fix a SEGV in previous commit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-03 21:11:27 +01:00
Denys Vlasenko
f9936676bb libpwdgrp: fix counting of commas in group list
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-03 21:03:39 +01:00
Denys Vlasenko
134c53098b libpwdgrp: store getXXnam result in a single malloc block
This saves a bit of memory but more importantly, allows to create
xmalloc_getpwnam() API where result can be deleted simply using free().

function                                             old     new   delta
getXXnam                                             134     173     +39
parse_common                                         188     212     +24
convert_to_struct                                    277     290     +13
get_S                                                 90      88      -2
tokenize                                             129     126      -3
bb_internal_getpwent_r                               175     172      -3
getXXnam_r                                           208     198     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/4 up/down: 76/-18)             Total: 58 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-03 20:47:47 +01:00
Denys Vlasenko
20c0a16334 libpwdgrp: make db->def[] one byte shorter
In the future I will need another uint8_t, want to fit it
w/o using another word on 32 bits.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-03 19:12:49 +01:00
Denys Vlasenko
5e62a3d016 libpwdgrp: use a better estimate of max struct size
Previous code's trick with bitwise OR was giving this on 32-bit x86:

sizeof(struct passwd):28
sizeof(struct group):16
sizeof(struct spwd):36
sizeof(struct_result):60

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-03 17:53:49 +01:00
Denys Vlasenko
9dca6acaac libpwdgrp: reinstate Tito's optional atexit freeing
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-03 16:09:05 +01:00
Denys Vlasenko
8d547aca75 libpwdgrp: fix a memory leak in getXXnam (we did not save address of string buf)
function                                             old     new   delta
convert_to_struct                                    261     269      +8
const_sp_db                                           20      24      +4
const_pw_db                                           20      24      +4
const_gr_db                                           20      24      +4
tokenize                                             144     147      +3
parse_common                                         185     188      +3
get_S                                                 82      85      +3
bb_internal_getpwent_r                               188     185      -3
gr_off                                                 4       -      -4
getXXnam                                             171     165      -6
pw_off                                                 7       -      -7
getgrouplist_internal                                237     229      -8
getXXnam_r                                           215     207      -8
sp_off                                                 9       -      -9
------------------------------------------------------------------------------
(add/remove: 0/3 grow/shrink: 7/4 up/down: 29/-45)            Total: -16 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-03 15:54:04 +01:00
Denys Vlasenko
31d6734457 libpwdgrp: tweak comments, replace one xmalloc with xzalloc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-03 15:15:47 +01:00
Denys Vlasenko
908b6e5dfd libpwdgrp: use FAST_FUNC to make "matching ABI" optimization more likely to succeed
See bb_internal_get*nam_r size reduction:

function                                             old     new   delta
bb_internal_getpwent_r                               167     176      +9
getXXnam_r                                           204     206      +2
sulogin_main                                         326     325      -1
su_main                                              471     470      -1
read_line_input                                     3832    3831      -1
print_stat                                           865     864      -1
prepare_socket_fd                                    283     282      -1
load_crontab                                         777     776      -1
fork_job                                             456     455      -1
do_shm                                               884     883      -1
do_sem                                               637     636      -1
do_msg                                               783     782      -1
complete_username                                    124     123      -1
bb_internal_getgrouplist                              71      70      -1
xgetpwuid                                             27      25      -2
xgetpwnam                                             27      25      -2
xgetgrnam                                             27      25      -2
xgetgrgid                                             27      25      -2
uid2uname                                             18      16      -2
login_main                                           980     978      -2
gid2group                                             18      16      -2
get_shell_name                                        54      52      -2
change_identity                                       50      48      -2
bb_internal_initgroups                                50      48      -2
argstr                                              1261    1259      -2
print_perms                                          177     174      -3
inetd_main                                          2077    2074      -3
run_applet_no_and_exit                               446     442      -4
fileaction_setowngrp                                  89      85      -4
deluser_main                                         312     308      -4
bb_internal_getpwuid                                  19      15      -4
bb_internal_getpwnam                                  11       7      -4
bb_internal_getgrnam                                  14      10      -4
bb_internal_getgrgid                                  19      15      -4
adduser_main                                         865     861      -4
passwd_main                                          989     984      -5
get_passwd                                            97      92      -5
data_extract_all                                     887     882      -5
check_user_passwd                                    490     485      -5
get_groups                                            81      75      -6
ftpd_main                                           2178    2171      -7
bb_internal_getspnam_r                                42      18     -24
bb_internal_getpwnam_r                                39      15     -24
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/41 up/down: 11/-153)         Total: -142 bytes
   text	   data	    bss	    dec	    hex	filename
 923167	    928	  17676	 941771	  e5ecb	busybox_old
 923023	    928	  17676	 941627	  e5e3b	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-02 22:31:07 +01:00
Tito Ragusa
1da09cfacf libpwdgrp: rewritten to use malloced implementation
This removed buffer size limitations.

function                                             old     new   delta
convert_to_struct                                      -     269    +269
getXXnam_r                                             -     204    +204
parse_common                                           -     185    +185
getXXnam                                               -     164    +164
tokenize                                               -     126    +126
bb_internal_getpwent_r                               102     167     +65
get_S                                                 30      88     +58
getgrouplist_internal                                195     240     +45
const_sp_db                                            -      20     +20
const_pw_db                                            -      20     +20
const_gr_db                                            -      20     +20
bb_internal_endpwent                                  27      36      +9
bb_internal_endgrent                                  27      36      +9
decode_one_format                                    726     734      +8
bb_internal_setpwent                                  17      24      +7
volume_id_probe_iso9660                              319     322      +3
scriptreplay_main                                    204     207      +3
mkfs_minix_main                                     2684    2687      +3
id_main                                              478     480      +2
hash_find                                            233     235      +2
pstree_main                                          321     322      +1
gr_off                                                 3       4      +1
expand_one_var                                      1579    1578      -1
pwf                                                    4       -      -4
grf                                                    4       -      -4
pack_gzip                                           1787    1780      -7
addattr32                                             67      56     -11
buffer_fill_and_print                                191     178     -13
dpkg_main                                           2944    2927     -17
bb_internal_setgrent                                  17       -     -17
bb_internal_getpwuid                                  38      19     -19
bb_internal_getgrgid                                  44      19     -25
bb_internal_getpwnam                                  38      11     -27
bb_internal_getgrnam                                  44      14     -30
bb_internal_fgetpwent_r                               51       -     -51
bb_internal_fgetgrent_r                               51       -     -51
bb_internal_getspnam_r                               121      42     -79
bb_internal_getpwnam_r                               121      39     -82
bb_internal_getgrent_r                               102       -    -102
bb__parsepwent                                       110       -    -110
bb_internal_getpwuid_r                               113       -    -113
bb_internal_getgrgid_r                               113       -    -113
bb__parsespent                                       120       -    -120
bb_internal_getgrnam_r                               121       -    -121
bb__pgsreader                                        213       -    -213
bb__parsegrent                                       226       -    -226
------------------------------------------------------------------------------
(add/remove: 8/13 grow/shrink: 14/11 up/down: 1224/-1556)    Total: -332 bytes
   text	   data	    bss	    dec	    hex	filename
 923471	    928	  17684	 942083	  e6003	busybox_old
 923167	    928	  17676	 941771	  e5ecb	busybox_unstripped

Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-02 21:37:59 +01:00
Denys Vlasenko
60cb48ca50 whitespace cleanup. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 15:57:44 +01:00
Denys Vlasenko
acdb0041b3 libpwdgrp/pwd_grp.c: use same static buffer for all getpwXX functions
This should save more than 0.5k of malloced memory in applets
which use those functions.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-01-06 16:24:56 +01:00
Denys Vlasenko
2e55404bcf libpwdgrp/pwd_grp.c: set opened /etc/{passwd,group,shadow} fds CLOEXEC
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-01-06 16:23:42 +01:00
Denys Vlasenko
4566e172eb simplify parsing of /etc/busybox.conf
function                                             old     new   delta
parse_config_file                                    799     667    -132

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-16 00:01:08 +02:00
Tito Ragusa
ad3d72f082 move passwd, shadow, group and gshadow path definitions to libbb.h
...and define them only if the used libc doesn't.

Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-16 23:39:45 +01:00
Denys Vlasenko
fb132e4737 whitespace cleanup
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-10-29 11:46:52 +02:00
Denys Vlasenko
e4dcba1c10 *: whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-28 18:57:19 +02:00
Denys Vlasenko
0ef64bdb40 *: make GNU licensing statement forms more regular
This change retains "or later" state! No licensing _changes_ here,
only form is adjusted (article, space between "GPL" and "v2" and so on).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-16 20:14:46 +02:00
Denys Vlasenko
da929a95aa mass renaming Kbuild -> Kbuild.src, Config.in -> Config.src
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-04 20:10:51 +02:00
Denys Vlasenko
05d1a32192 libpwdgrp: comment out unused data
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-04-02 12:12:43 +02:00
Denys Vlasenko
8d22ca81c3 libpwdgrp: comment out more unused functions
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-31 14:43:58 +02:00
Denys Vlasenko
55301297d3 libpwdgrp: comment out functions with UNUSED_SINCE_WE_AVOID_STATIC_BUFS
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-31 12:38:17 +02:00
Denys Vlasenko
17fcd72add libpwdgrp: style cleanups
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-31 12:37:43 +02:00
Denys Vlasenko
9e59e27cdf libpwdgrp: code style fixes, no real code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-31 10:31:51 +02:00
Denys Vlasenko
57dc3c7b4c libpwdgrp: can't depend on strlen(line_buff) != 0
function                                             old     new   delta
bb__pgsreader                                        188     202     +14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-31 10:24:37 +02:00
Denys Vlasenko
1f27ab0d4b *: optimize code size in strtoul calls
function                                             old     new   delta
bb_parse_mode                                        433     431      -2
rtnl_rtntype_a2n                                     202     198      -4
ParseField                                           511     498     -13
bb_init_module_24                                   4730    4675     -55
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-74)             Total: -74 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-23 17:17:53 +02:00
Denys Vlasenko
9b1b62adc4 Patches to enable FreeBSD build
platform.h: fix wrong check for endianness, fix lchown
aliasing to chown on uclibc.

Code seems to not be affected in my testing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-05 03:34:12 +02:00
Denis Vlasenko
6826441a02 remove redundant NULL check 2008-09-27 23:39:55 +00:00
Denis Vlasenko
ee5dce3365 libpwdgrp: make it coexist with <pwd.h>, <grp.h> and <shadow.h>.
allows to get rid of hacks in libbb.h (extra declaration of setgroups -
 now it comes from grp.h as intended).
2008-09-26 10:35:55 +00:00
Denis Vlasenko
2228426512 id: fix "id <user>" case. Requires getgrouplist().
function                                             old     new   delta
getgrouplist_internal                                  -     200    +200
id_main                                              462     539     +77
bb_internal_getgrouplist                               -      67     +67
bb__parsespent                                       119     117      -2
bb_internal_initgroups                               213      58    -155
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 1/2 up/down: 344/-157)          Total: 187 bytes
2008-09-18 00:56:24 +00:00
Denis Vlasenko
8d89bed840 watchdog: add -T option
function                                             old     new   delta
 watchdog_main                                        159     219     +60
mdev: support match by major,minor. See bug 4714.
 +100 bytes.
2008-09-07 23:22:08 +00:00
Denis Vlasenko
5415c856ea libbb: [x]fopen_for_{read,write} introduced and used.
(by Valdimir)

function                                             old     new   delta
config_open2                                           -      41     +41
config_read                                          507     542     +35
find_pair                                            169     187     +18
fopen_for_write                                        -      14     +14
fopen_for_read                                         -      14     +14
find_main                                            406     418     +12
xfopen_for_write                                       -      10     +10
xfopen_for_read                                        -      10     +10
popstring                                            134     140      +6
parse_inittab                                        396     401      +5
next_token                                           923     928      +5
pack_gzip                                           1659    1661      +2
bb__parsespent                                       117     119      +2
fallbackSort                                        1719    1717      -2
evalvar                                             1376    1374      -2
qrealloc                                              36      33      -3
...
...
...
...
singlemount                                         4579    4569     -10
process_stdin                                        443     433     -10
patch_main                                          1111    1101     -10
ifupdown_main                                       2175    2165     -10
file_action_grep                                      90      80     -10
uuidcache_init                                       649     637     -12
hush_main                                            797     785     -12
read_config                                          230     217     -13
dpkg_main                                           3835    3820     -15
read_line_input                                     3134    3110     -24
sysctl_main                                          232     203     -29
config_open                                           40      10     -30
WARN_BAD_LINE                                         44       -     -44
login_main                                          1714    1575    -139
------------------------------------------------------------------------------
(add/remove: 5/1 grow/shrink: 8/74 up/down: 174/-737)        Total: -563 bytes
2008-07-21 23:05:26 +00:00
Denis Vlasenko
b74a2dba57 whitespace fixes, no code changed 2008-07-21 21:34:51 +00:00
Bernhard Reutner-Fischer
d73cbd31a2 - first pass to unify/cleanup uid handling (-236b)
This needs further love, alot of love.. Tito?
2008-07-21 14:41:33 +00:00
Denis Vlasenko
deeed59de0 libbb: introduce and use xrealloc_vector
function                                             old     new   delta
xrealloc_vector_helper                                 -      51     +51
create_list                                           84      99     +15
getopt_main                                          690     695      +5
passwd_main                                         1049    1053      +4
get_cached                                            85      89      +4
msh_main                                            1377    1380      +3
add_match                                             42      41      -1
read_lines                                           720     718      -2
grave                                               1068    1066      -2
fill_match_lines                                     143     141      -2
add_to_dirlist                                        67      65      -2
add_input_file                                        49      47      -2
act                                                  252     250      -2
fsck_main                                           2252    2246      -6
man_main                                             765     757      -8
bb_internal_initgroups                               228     220      -8
cut_main                                            1052    1041     -11
add_edge_to_node                                      55      43     -12
dpkg_main                                           3851    3835     -16
ifupdown_main                                       2202    2178     -24
sort_main                                            838     812     -26
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 5/15 up/down: 82/-124)          Total: -42 bytes
2008-07-08 05:14:36 +00:00
Denis Vlasenko
defc1ea340 *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on
text    data     bss     dec     hex filename
 808035     611    6868  815514   c719a busybox_old
 804472     611    6868  811951   c63af busybox_unstripped
2008-06-27 02:52:20 +00:00
Denis Vlasenko
9230582315 inetd: use change_identity().
libbb: shrink our internal initgroups().
httpd: remove stray 'else' and 'index_page = "index.html"'

function                                             old     new   delta
httpd_main                                           750     743      -7
inetd_main                                          2033    2011     -22
bb_internal_initgroups                               251     228     -23
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-52)             Total: -52 bytes
2008-03-20 15:12:58 +00:00
Denis Vlasenko
6ca409e0e4 trylink: produce even more info about final link stage
trylink: explain how to modify link and drastically decrease amount
  of padding (unfortunately, needs hand editing ATM).
*: add ALIGN1 / ALIGN2 to global strings and arrays of bytes and shorts

size saving: 0.5k
2007-08-12 20:58:27 +00:00
Denis Vlasenko
b71c668c57 style fix (stray space before ';') 2007-07-21 15:08:09 +00:00
Denis Vlasenko
2c91efb7c2 libpwdgrp/pwd_grp.c: allocate local storage on first call, not in bss. -1k bss
function                                             old     new   delta
get_S                                                  -      31     +31
bb_internal_getpwnam                                  38      44      +6
bb_internal_getgrnam                                  38      44      +6
bb_internal_getgrgid                                  38      44      +6
ptr_to_statics                                         -       4      +4
static.resultbuf                                      88       -     -88
static.buffer                                       1024       -   -1024
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 3/0 up/down: 53/-1112)        Total: -1059 bytes
2007-06-18 10:08:27 +00:00
Denis Vlasenko
b6adbf1be2 usage.c: remove reference to busybox.h
*: s/include "busybox.h"/include "libbb.h"
2007-05-26 19:00:18 +00:00
Denis Vlasenko
78e48b2c2c we were basically ignoring CONFIG_USE_BB_PWD_GRP (assuming =y),
fix this
2007-05-18 00:02:37 +00:00