Andre Noll [Fri, 21 Aug 2009 11:25:04 +0000 (13:25 +0200)]
Transform the database_dir/database_root arg into an absolute path.
adu --create failed badly if called with --database_dir or
--database_root being relative path. This patch fixes the bug.
Unfortunately, it's not completely trivial to obtain the cwd
in a portable and secure manner. The method used in the
new absolute_path() function, while still not bullet-proof, is
the best what one can do if portability is an issue.
Andre Noll [Mon, 15 Jun 2009 18:14:30 +0000 (20:14 +0200)]
Documenatation improvements.
This patch adds an illustration of the user-list mode to README and an
examples section to the man page. Thanks to Klaus Kopec who suggested
this improvement.
Sebastian Stark [Wed, 4 Feb 2009 10:16:01 +0000 (11:16 +0100)]
new option database-root
If database-root is given, the database dir is computed by
appending the base dir to it. Obviously this works only if
base dir is given, even for select mode.
The needed directory structure is created below database-root
by the new function mkpath(), which recursively creates any
directory needed to copy the structure of base dir. This
has the side-effect that the database dir is always created
for the user (if permissions allow) which wasn't the case
before.
database_dir is now a global variable just like conf and should
be used whenever conf.database_dir_arg was used before.
Andre Noll [Tue, 23 Dec 2008 16:26:52 +0000 (17:26 +0100)]
Make it compile on FreeBSD and NetBSD.
off_t on BSD is 64 bit even on 32bit machines, so there are no
special tricks needed to get large file support. In fact, getconf
has no options for large file support and struct stat64 and lstat64()
do not exist on BSD systems. This caused the compilation to fail on
those systems.
Fix this problem by checking for BSD via uname -s in the Makefile. If
uname indicates we're on BSD, then do not use getconf and #define
stat64 and lstat64() to stat and lstat() respectively.
Andre Noll [Wed, 17 Dec 2008 22:32:21 +0000 (23:32 +0100)]
Fix a design bug concerning struct user_info.
It was a bad idea to include the accounting data (#files, #dirs,
information about the user only.
So move the accounting data to user_summary_info. This allows
to get rid of the ugly uid_hash_table_sort_idx construct and of
sort_hash_table(). These were only needed because of the broken
design. We now never sort the hash table but allocate an array of
user_summary_info structures on each query and sort that array instead.
This patch not only simplifies code but also fixes a real bug noted by
Sebastian Stark: If the user_summary was requested more than once in
interactive mode, the old code computed incorrect values because the
above mentioned accounting fields were only initialized once. The new
code gets this right automatically because a fresh array is created
on each query.
Andre Noll [Sun, 9 Nov 2008 19:37:09 +0000 (20:37 +0100)]
Make the header line configurable.
This replaces the --no-header flag by --header string option. The
argument is the header of the summary/list.
This was not a straight-forward task because the headers for the
user lists contain the uid and the user name. So introduce another
set of format string directives to still allow this.
Andre Noll [Sun, 9 Nov 2008 14:33:16 +0000 (15:33 +0100)]
Fix sorting of the uid hash table.
We must not blindy sort the whole table because in interactive mode
this table may be modified by later commands and lookup_uid() gets
confused if the entries have been permuted. So introduce
uid_hash_table_sort_idx, an array of indices that describes the current
sorting of the hash table. The order of the entries in the table itsself
never gets changed any more with this patch.
Also, simplify the uid comparators by introducing a wrapper that does
the casts which were previously contained in each comparator.
Andre Noll [Sun, 9 Nov 2008 00:45:42 +0000 (01:45 +0100)]
Do not close tables on each query.
This speeds up interactive mode where many queries may be executed
in a row. User tables are opened on demand (if the uid is admissible)
and only closed on exit. Also the dir table is opened only once per
session rather than on each query.
Andre Noll [Sat, 8 Nov 2008 22:05:54 +0000 (23:05 +0100)]
User handling improvments.
- move global variable num_uids to user.c.
- logging improvements.
- replace search_uid() by create_user_table(). search_uid() had a
horrible interface.
- in user.c, use FOR_EACH_USER() to loop over all users rather than
for_each_admissible_user().
Andre Noll [Wed, 5 Nov 2008 17:30:28 +0000 (18:30 +0100)]
Fix return codes for loop functions.
The four different loop functions must set the return value in
their private struct because these functions are called from
within the osl library which will replace any negative return value
by -E_OSL_LOOP.
Andre Noll [Sat, 1 Nov 2008 22:45:47 +0000 (23:45 +0100)]
Improve interactive feeling, kill dump command.
It's no good to spam the user with syntax errors on empty lines.
In popular shells, the set command prints the current environment
if called without arguments. So do the same and kill the dump command.