Andre Noll [Thu, 1 Sep 2016 15:13:50 +0000 (17:13 +0200)]
create: Make the directory scan more robust.
The directory traversal of adu calls adu_opendir() of fd.c for every
subdirectory. If this call fails with EACCESS, a warning is printed
but the operation continues, ignoring the directory which could not
be accessed. Other errors are considered fatal, though, and adu aborts
in this case.
This patch continues to scan in this case. This is achieved by making
all errors from adu_opendir non-fatal. In the error case we print a
warning and ignore the directory, but no longer abort.
Thanks to Steffen Schmidt for pointing out this flaw.
Andre Noll [Thu, 2 Jun 2016 15:37:26 +0000 (17:37 +0200)]
Abort if neither --database-dir nor --base-dir is given.
If --database-dir is not given, adu concatenates the database root
directory (which defaults to /var/lib/adu) with the value of the
--base-dir argument. However, if --base-dir is not given either,
base_dir_arg is NULL, and the concatenated string becomes the result
is /var/lib/adu(null), at least on glibc.
With this patch applied, adu handles this case more gracefully: it
prints an error message and aborts early.
Andre Noll [Mon, 6 Jun 2016 06:46:09 +0000 (08:46 +0200)]
build: Don't remove adu.png on make clean.
This was appropriate with the old logo which was generated from a
.sk source file. The new logo, however, only exists in png format,
so we should never remove it.
The adu.sk~ file can also be skipped from the list of files to be
removed by make clean.
Andre Noll [Sat, 4 Jun 2016 14:43:43 +0000 (16:43 +0200)]
fd.c: Avoid gcc warning regarding fchdir().
gcc-4.8.4 on Ubuntu-14.04 complains about our use of fchdir():
fd.c:181:9: warning: ignoring return value of ‘fchdir’, declared with attribute warn_unused_result [-Wunused-result]
fchdir(*cwd);
Silence the warning by introducing a dummy variable. The patch also
fixes the indentation of the comment which explains why we ignore
the return value here.
Andre Noll [Wed, 20 Apr 2016 18:43:44 +0000 (20:43 +0200)]
adu-1.0.0.
This project is done. In fact it was done already five years ago
and has seen only a couple of minor fixes since then. With the new
version number it does not look like the project is dead.
Andre Noll [Tue, 19 Apr 2016 12:59:08 +0000 (14:59 +0200)]
Fix gitweb link.
Although on the gitweb server there is a link adu -> adu.git, the
link on the main page does not work without the .git suffix. This
used to work at some point...
Andre Noll [Sun, 15 Feb 2015 15:42:05 +0000 (16:42 +0100)]
Simplify and rename mmap_full_file().
There is only one caller which maps the file privately into read-only
memory. Moreover, this caller does not care about the file descriptor
from which the mapping was created.
This commit removes the argument from mmap_full_file() which control
the type of the map and the result pointer for the file descriptor,
thereby simplifying the function slightly. Rename it to mmap_file_ro()
to indicate that read-only private mappings are implied.
Andre Noll [Sat, 3 Jan 2015 21:36:17 +0000 (21:36 +0000)]
Make fd.c and select.c include their own header file.
This helps to spot bugs where declaration and implementation
differ. Fortunately, there is so such bug in adu, but it's a good thing
(TM) to let the compiler error out in this case.
Andre Noll [Mon, 11 Aug 2014 16:15:00 +0000 (18:15 +0200)]
Add new logo.
To paraphrase a similar change in the ratpoison project: it was hard
to say good-bye to the old logo but sometimes we just have to let the
past be the past.
Andre Noll [Wed, 15 Aug 2012 20:44:19 +0000 (22:44 +0200)]
interactive.c: Return proper error on icom_set() failure.
If an interactive set command fails, we currently reset the
configuration to the default and return success. This is probably
not what the user expected.
Andre Noll [Sun, 9 Jun 2013 15:48:36 +0000 (17:48 +0200)]
Fix user summary accounting if pattern is given.
In user summary select mode we iterate over each row in the user
info table and get the directory name from the number stored in the
row. Next we match this name against the given pattern and only take
matching directories into account for the user summary.
Currently we call get_dir_name_of_row(), but this is wrong:
Since we iterate over the user info table, we must call
get_dir_name_of_user_row() instead as the former function expects a
pointer to a dir table row.
This bug caused wrong directory names to be matched against the
pattern, hence the results of the user summary were incorrect.
Andre Noll [Sun, 9 Jun 2013 16:31:55 +0000 (18:31 +0200)]
Avoid gcc warning.
Introduce a default case for the body of the switch statement in
print_statistics() to avoid the following gcc-4.8.1 warning:
select.c: In function 'print_statistics':
select.c:806:2: warning: enumeration value 'select_mode__NULL' not handled in switch [-Wswitch]
switch (select_conf.select_mode_arg) {
^
Andre Noll [Mon, 25 Jun 2012 18:59:17 +0000 (20:59 +0200)]
split_args(): Do not insist on checking the return value.
Currently, split_args() of string.c has the __must_check attribute
which instructs gcc to warn whenever the return value of this function
is ignored by the caller.
However, since the returned array is NULL terminated anyway, there
are situations the return value my safely be ignored, for example if
the returned array is passed to execvp(), which does not receive a
length argument.
This patch removes the __must_check attribute and fixes a "set but
not used" warning on newer gcc versions.
Andre Noll [Mon, 25 Jun 2012 18:48:53 +0000 (20:48 +0200)]
Fix check for return value of catch_signal().
Commit 2d7a4d61 made adu's signal handling portable by switching from
signal() to sigaction() for installing signal handlers. This commit
added the new function catch_signal() which returns the return value
of the underlying call to sigaction(), i.e. zero on success, and -1
on errors.
However, embarrassingly enough, one caller of catch_signal() still
checked this return value against SIG_ERR, which is the value that
is returned from signal() on errors.
Fix this bug by testing the return value against zero.
Andre Noll [Mon, 25 Jun 2012 16:23:15 +0000 (18:23 +0200)]
Makefile: Honor CPPFLAGS also when creating dependencies.
Makefile.deps is created using a cc -MM -MG command which might need
the CPPFLAGS provided by the user, just as the ordinary cc commands
for creating an object file.
For example, the user might have passed -I$HOME/include, since
libosl was installed in $HOME. In this case we need to pass
this to the cc command that creates the Makefile as well.
Andre Noll [Thu, 2 Feb 2012 16:07:35 +0000 (17:07 +0100)]
Fix signal handling.
Using signal() to set the disposition of a signal is always a bad idea
as POSIX does not specify whether a system call which was interrupted
should be restarted or not.
For interactive sessions, the Linux behaviour is to automatically
restart slow system calls, specifically read(2) in case nothing had
been read before the interrupt arrived. This is rather unfortunate
as adu calls fgets(3) (hence read(2)) in an endless loop to read the
user input. Therefore automatically restarted read() calls result
in interactive sessions that can not be terminated easily, as was
noticed by Sebastian Stark.
This patch makes the signal initialization code call sigaction()
instead of signal() to set up the handlers. This buys us well-defined
semantics across all operating systems, namely to *not* restart slow
system calls. As a side effect of this change, interactive sessions
can now be terminated by sending SIGINT (e.g., by pressing CTRL+C).
Andre Noll [Mon, 2 Nov 2009 13:43:51 +0000 (14:43 +0100)]
Set CC to gcc by default.
On systems where cc != gcc, compilation likely fails because we are
using quite some gccisms in adu. So default to gcc but let the user
override the default by setting CC manually.
The straight-forward CC ?= gcc does not work with gnu make as make
assigns CC the default value "cc".
Thanks to Steffen Schmidt for pointing out this shortcoming.
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.