Andrew Deason [Wed, 10 Aug 2011 15:23:40 +0000 (10:23 -0500)]
volinfo: Include nfs.h
nfs.h is required for various types used in vol-info.c. Include it. On
namei this header gets pulled in indirectly via other means, but on
inode it does not (and we shouldn't be relying on such anyway).
Simon Wilkinson [Wed, 27 Jul 2011 10:30:51 +0000 (11:30 +0100)]
pts: Add the -config option
Add the -config option to all pts commands, so that the user can set
the location of the configuration directory to use. This is primarily
provided for testing purposes, to make it simpler to build fake AFS
cells with configuration in non-standard locations.
Garrett Wollman [Tue, 9 Aug 2011 03:19:22 +0000 (23:19 -0400)]
dir/vol: Die() really does
Die() is an abort routine shared by the dir and vol modules. Move its
prototype into dir.h to ensure that its declaration matches its three
different definitions, and add an AFS_NORETURN annotation so that the
static analyzer knows that it aborts.
Garrett Wollman [Tue, 9 Aug 2011 02:49:24 +0000 (22:49 -0400)]
vos: eliminate unnecessary global variables
tserver is used by three different functions but not shared by them;
make it private to each one to improve static analysis. tconn is
not used by anything, so just delete it.
Garrett Wollman [Tue, 9 Aug 2011 01:41:57 +0000 (21:41 -0400)]
volser: let it be known that Abort() really aborts
The compiler and static checkers can do a better job if they know that
certain functions never return. Tell it that common.c:Abort() is such
a function. While we're at it, let volser_internal.h provide the
declarations for this function (Log() was already there). This makes
volser parallel to the way the same functions are declared in vol.
Garrett Wollman [Tue, 9 Aug 2011 01:18:15 +0000 (21:18 -0400)]
kdb: don't dereference a null pointer on corrupt database
When iterating through the database, kdb would dereference a
null pointer if it encountered an error retrieving the value
or if the value was not the right length, in code that was clearly
cut-and-pasted from the other branch of an "if" statement where a
specific entry was requested on the command line. Print the name
of the entry with the problem as was apparently intended.
Garrett Wollman [Sun, 7 Aug 2011 04:09:33 +0000 (00:09 -0400)]
afs_pioctl: don't use cell uninitialized in PGetTokens2
An unlikely error condition could lead to the variable cell in
PGetTokens2 being passed uninitialized to afs_PutCell. Initialize
it to NULL beforehand to avoid this.
in the new lwp/pthread/shared universe, well, we have the
opportunity to be correct. and we chose to do it entirely wrong.
we're building a shared object. use the right rules. we need
to add some CFLAGS for PAM. do that using MODULE_CFLAGS instead
of just building a whole new CCRULE
don't define variables on platforms we won't use them on
do prototype functions we call. basically, we compile with warnings
enabled now, so, fix everything so we *can*.
Garrett Wollman [Sun, 7 Aug 2011 03:49:10 +0000 (23:49 -0400)]
butc: avoid testing stack garbage; remove dead initializer
"code" is unconditionally set early in saveDbToTape() so there's
no need to initialize it. On the other hand, dumpEntry.id is used
before dumpEntry is initialized, so set it to what appears to be
the expected value before any non-local exits could cause it to be
inspected.
Garrett Wollman [Sun, 7 Aug 2011 03:36:14 +0000 (23:36 -0400)]
butc: initialize startTime before it is used
In some unusual error situations, startTime may be used uninitialized.
Move the initialization up above the first such error condition.
(None of the intervening code can take measurably long to execute
so this should not make any difference in the non-error case.)
Garrett Wollman [Sun, 7 Aug 2011 03:15:14 +0000 (23:15 -0400)]
vos: don't free stack garbage on error
If wantExtendedInfo is true, then pntr is used uninitialized.
In the other case, UV_ListVolumes will have set it to NULL
before doing anything (even if it returns an error), so this
free() is dead anyway.
Simon Wilkinson [Wed, 3 Aug 2011 18:08:20 +0000 (19:08 +0100)]
libafsauthent: Add volser and vldb
Add the volser and vldb families of functions to libafsauthent. This
allows applications such as per-AFS which are building pthreaded clients
to use a single library, rather than trying to mix LWP and pthreaded
code within the same process.
Simon Wilkinson [Wed, 3 Aug 2011 17:45:01 +0000 (18:45 +0100)]
volser doesn't depend on tviced, but on vlserver
Nothing within the volser/ directory depends on tviced, so remove the
unecessary dependency. Add an explicit dependency on vlserver, so that
libvldb is available to us.
This is required to get rid of some potential circular loops when we
start including volser objects in libafsauthent
Jeffrey Altman [Thu, 4 Aug 2011 21:25:01 +0000 (17:25 -0400)]
Windows: adjust scache LRU postion upon deletion
If the object represented by a scache object is deleted,
update the LRU position of the scache object to make it
the first object in the LRU queue to be recycled. This
preserves the cached objects for those that might prove
useful in the future.
Instead of using malloc() and free() to allocation lock reference
structures, cache allocated objects in a free list. This reduces
memory fragmentation.
Jeffrey Altman [Thu, 4 Aug 2011 21:08:45 +0000 (17:08 -0400)]
Windows: after dir enum adjust dir scache LRU
During a directory enumeration the directory scache object
is reference counted so it can't be recycled. However, if
there are more directory entries than the maximum number
of cached scache objects the directory scache object will
end up being the next object to be recycled after the refcount
is dropped. Since the directory is clearly a hot object, before
dropping the reference, adjust the scache LRU position so that
it is the last object to be recycled.
Fix the variable name for the directory scache to be 'dscp'
for consistency.
Jeffrey Altman [Mon, 1 Aug 2011 15:05:51 +0000 (11:05 -0400)]
Windows: conditionalize mappings of error values
Visual Studio 10 adds a large number of additional POSIX C99
error values to errno.h. Wrap each mapping with #ifndef to ensure
that we do not redefine the C runtime errno.h definition.
Jeffrey Altman [Mon, 1 Aug 2011 15:00:55 +0000 (11:00 -0400)]
Windows: unified afs errors must use nt mapping
On Windows, error.h does not provide a complete list of POSIX
C99 error values. OpenAFS fills in the gaps with a private
error mapping table afs/errmap_nt.h (src/util/errmap_nt.h).
If errmap_nt.h is not included prior to processing unified_afs.h,
values such as ELOOP will be mapped to EIO instead of the unique
value defined by errmap_nt.h.
Andrew Deason [Fri, 29 Jul 2011 21:44:11 +0000 (16:44 -0500)]
SOLARIS: Do not release NULL root vp on unmount
When we unmount, and afs_globalVp is NULL (e.g. because root.afs was
unavailable when the client was started), we will panic the machine if
we try to release it. So, if afs_globalVp is NULL when we hit our
unmount handler, don't touch it.
Will Maier [Sun, 31 Jul 2011 13:24:12 +0000 (14:24 +0100)]
RedHat: Return status values from client init
The init script provided with OpenAFS always returns 0 when the status
subcommand is called, even if the service is not running.
For example:
$ sudo service afs status; echo $?
afsd is stopped
0
This change makes sure the init script exits with the value returned
by the status function from /etc/init.d/functions. With this patch,
the afs init script behaves as expected when used, for example, in a
Chef service resource:
$ sudo service afs status; echo $?
afsd is stopped
3
If a cm_BkgDaemon thread finds a queued request whose cm_scache_t
has the CM_SCACHEFLAG_DELETED flag set, do not execute the request
and fail it immediately with CM_ERROR_BADFD. Any attempt to execute
the request will fail with VNOVNODE from the file server.
Windows: cm_BkgDaemon should not do cm_SyncOp's job
cm_SyncOp is designed to synchronize operations among multiple
threads. The background daemon threads should not filter requests
based upon cm_SyncOp states. Doing so is racy and does not produce
better performance.
If the cm_scache_t flags include CM_SCACHEFLAG_DELETED, do not
bother releasing an outstanding file lock to the file server.
The lock went away when the file was deleted. Any attempt to
release will fail with VNOVNODE which is translated locally into
CM_ERROR_BADFD.
If a RXAFS_ReleaseLock RPC fails with VNOVNODE, treat it as
success.
Add PERL variable to the build system. If not specified
externally the variable will be set to 'perl'. However,
ActiveState Perl should be used and not Cygwin Perl. The build
environment should indicate that by specifying a PERL setting.
On Windows, the git repository is checked out as CR-LF.
Tell perl to open the pod file with cr-lf as the end of line.
On Windows, the input file names are of the form podX\foo.pod.in.
Cygwin perl cannot parse the directory for the file name unless
the path separator is converted from \ to /.
The userrealm string in KFW_AFS_get_cred() should not include
the '@' symbol from the user principal. Including the '@' produces
an invalid realm name.
Add KTC and PT error messages to those that can be
translated within afskfw.lib. This improves the error
logging for afslogon.dll, afscreds.exe, and afssrvadm.exe
Andrew Deason [Wed, 20 Jul 2011 21:50:52 +0000 (16:50 -0500)]
libafs: Rate-limit hard-mount waiting messages
Limit how often we log "hard-mount waiting for XXX" messages. Without
this, it is possible for a client with hard-mounts enabled to spam the
kernel log rather excessively (in extreme cases this can even panic
the machine on at least some Linux).
To keep things simple, just log approximately one message per volume
per hard-mount interval.
Simon Wilkinson [Sun, 10 Jul 2011 12:56:21 +0000 (13:56 +0100)]
util: Don't use FT_GetTimeOfDay for MRAFS logs
FT_GetTimeOfDay creates an LWP dependency. For the purpose that we're
using it in serverLog.c, gettimeofday performs identically. So, just
use gettimeofday and reduce our dependencies.
In the startup function for each thread, set a thread name. This
can safely be done unconditionally as LWP builds turn the call into
a no-op. In general, the thread name parallels the name passed to
LWP_CreateProcess, but for Rx server threads, it additionally includes
the thread ID so that these threads can easily be distinguished. (I'm
not sure yet whether doing so will prove to be useful or counterproductive.)
Andrew Deason [Mon, 25 Jul 2011 16:12:37 +0000 (11:12 -0500)]
libafs: Add afs_conn refCount imbalance safeguard
If someone is putting back too many refs, we can detect so very
easily. If we see that such a thing is happening, give a warning and
bail out, instead of risking a panic or memory corruption.
libuafs: don't use a GNU-only feature in a common makefile
$(shell ...) is a GNU Make proprietary feature and shouldn't be used
OS-independent makefiles. There is no need to use it here; command
substitution in the shell is good enough.
because of how the root fid is created we can end up being dumb.
turns out we never want to bypass doing the full pass for root anyway
so just force fixup to not happen.
Andrew Deason [Fri, 22 Jul 2011 21:09:52 +0000 (16:09 -0500)]
libafs: Avoid duplicate afs_Analyze in bulk stat
In afs_DoBulkStat, we can call afs_Analyze multiple times for the same
set of connection objects. Since afs_Analyze puts its reference to the
given afs_conn and rx_connection structures, calling it more than once
can cause the reference counts on those objects to be lower than they
should be.
Instead of making another afs_Analyze call, just alter the error code
inside the normal do/while afs_Analyze loop, so the 'loop' afs_Analyze
call gets the appropriate error code from the first bulk stat'd entry.
Add --with-gssapi*, --with-libintl*, and --with-roken for the new
library location flags. Add --with-docbook2pdf and
--with-docbook-stylesheets for the automatic discovery of tools for
building the documentation. Expand and correct the descriptions of
--with-html-xml and --with-xslt-processor.
Clean and ignore additional build files for DocBook documentation
Depending on what generation method is used for the DocBook
documentation, additional build files may be created. One of those
(*.aux) will cause the build to break if one switches from
docbook2pdf to dblatex without deleting it. Update make clean
and .gitignore to remove and ignore these additional files.
Ben Kaduk [Sat, 23 Jul 2011 18:58:54 +0000 (14:58 -0400)]
FBSD: cast lkmnosys appropriately
lkmnosys is a function, and as such has its own prototype which
includes a named struct specific to it (struct nosys_args). When
comparing its address to an entry in the syscall table, we must
cast it to a sy_call_t to correctly do the comparison, lest gcc
warn us about comparing distinct pointer types without a cast.
This warning recently became an error due to bsd.kmod.mk, so it
causes the build to fail on 8.1 and earlier, which do not use
syscall_register() due to a conflicting entry for our syscall
in syscalls.master.
Simon Wilkinson [Sun, 10 Jul 2011 12:54:20 +0000 (13:54 +0100)]
util: Cleanup generation of dirpath.h
dirpath.h is only copied into place if it has changed. However, this
means that the timestamp of dirpath.h is never updated, causing make to
always trigger the buildrule, even if the rule eventually does nothing.
Instead, always copy in the new dirpath.h, which simplifies the make
rules, and stops make from always building.
Simon Wilkinson [Mon, 4 Jul 2011 09:03:50 +0000 (10:03 +0100)]
klog.krb5: Don't use ubik_PR_NameToID internal func
ubik_PR_NameToID is a low level function which requires a large amount
of setup from the caller. Instead, use pr_Initialize() and pr_SNameToId()
which do all of the work in a library.
Simon Wilkinson [Tue, 15 Jun 2010 15:51:42 +0000 (16:51 +0100)]
ptserver: Don't print undefined value
The readgroup utility printed the wrong variable when listing the
source group - instead of printing the group name, it tried to
print an arbitrary element from the list of group members. Fix it
to print the right thing.
Andrew Deason [Wed, 20 Jul 2011 20:33:41 +0000 (15:33 -0500)]
libafs: Remove unused volume "states" flags
VResort and VMoreReps are not referenced anywhere in the tree, so
remove their definitions. Keep VPartVisible for VICEP-ACCESS, but
lower it to the next unused bit.
the shimmed heimdal in Lion crashes on this call now.
the shim also exports diddly squat. fine, we pick over what
IS exported and use only calls available to us.
Andy Cobaugh [Fri, 15 Jul 2011 16:06:12 +0000 (12:06 -0400)]
rpm: remove postinstall message from openafs-client
Printing out information on how to configure cacheinfo and ThisCell
is a bit noisy, and pam_afs.so is probably not what most people
want to use nowadays.
During Windows OS shutdown the service may be given as little
as six seconds to shut itself down before it will be terminated.
Forced termination will leave the cache file in a dirty state.
This patchset makes several minor changes to reduce the overall
time required for shutdown:
1. do not wait for the IP address change notification thread.
by the time it terminates the ip address has been lost.
2. send give up all callbacks earlier.
3. reorder the daemon thread waits.
4. change the daemon thread loop sleep time to 500ms in order
to prevent the service from waiting up to 10 seconds for
the thread to notice a shutdown is in progress.
When computing whether or not to perform an offline volume
check it is critical that the 'lastBusyVolCheck' variable
be assigned the current time instead of 'lastVolCheck'.
By setting the wrong variable a new offline volume check is
performed every 10 seconds which is undesireable.
Add an explicit message that the shutdown sequence is complete.
This is necessary because during a Windows OS shutdown, the service
is frequently killed prior to the memory mapped file is fully released.
Andrew Deason [Tue, 19 Jul 2011 21:44:21 +0000 (16:44 -0500)]
Revert "afs: Use 64-bit inode numbers"
This reverts commit e1e008338639d6cc0d836ff8079e6fb42021ab9e. Using
64-bit inode numbers can make AFS largely inaccessible to 32-bit
programs that are not compiled with large file support, since the
inode number we provide is not representable in a 32-bit struct stat.
Using 64-bit inode numbers thus can break quite a few programs, and
has little benefit, so don't do it.
Ben Kaduk [Tue, 21 Jun 2011 02:46:01 +0000 (22:46 -0400)]
FBSD: update to using bsd.kmod.mk
We have for a long time had a cobbled-together kernel module build
system that essentially copied build arguments from a kernel build
in an ad hoc fashion, with lots of conditionals on architecture
and OS version. (We got it wrong, several times, too.)
Instead, use the supported mechanism for building kernel modules,
which allows us to remove a lot of code from the Makefile and gives
us some measure of future-proofing.
Ben Kaduk [Sun, 17 Jul 2011 20:24:12 +0000 (16:24 -0400)]
libafs: switch to hardcoded source names with CRULE
Most of the userspace tree uses AFS_CCRULE for how to compile
things. We cannot use this directly for libafs, since in the
general case kernel and userland code may need to be treated
with an entirely different compiler and compiler options.
Switching libafs fully to a (e.g.) LIBAFS_CCRULE would be a substantial
amount of work, and require a lot of testing. However, we can
stop passing -c $? (the out-of-date sources) in CRULE_{NO,}OPT
and add the source file after each invocation of the CRULEs,
an incremental step towards LIBAFS_CCRULE.
This has the extra advantage of not causing issues when integrating
with kernel module build systems that automatically add dependencies
to all object file targets. (In such cases, $? expands to multiple files
and 'gcc -o foo.o -c' bails out.)
Most of this change was automatically generated from the following
awk script:
==========
/[a-zA-Z_0-9].o:/ {path=$2;}
/^ \$\(CRULE_/ {print $0,path;}
!/^ \$\(CRULE_/ {print;}
==========
Ben Kaduk [Tue, 21 Jun 2011 02:35:08 +0000 (22:35 -0400)]
FBSD: use better casts in vop_advlock
In the bsd.kmod.mk world, the compiler bails when we cast a pointer
directly to int. Cast through intptr_t as the supported mechanism.
On amd64, this loses bits, but since this instance is just attempting
to use the value as a unique handle, it is probably okay for now.
However, it should be addressed more properly eventually, when
this locking implementation sees wider use.
Change-Id: I4fe8084c14a97dc4efc8d74e9971b1540c028e40
Reviewed-on: http://gerrit.openafs.org/5034 Reviewed-by: Matt Benjamin <matt@linuxbox.com> Reviewed-by: Garrett Wollman <wollman@csail.mit.edu> Reviewed-by: Derrick Brashear <shadow@dementia.org> Tested-by: Derrick Brashear <shadow@dementia.org>
Ben Kaduk [Sat, 25 Jun 2011 04:33:41 +0000 (00:33 -0400)]
FBSD: Use correct path for ufsmount.h include
The two lines above it already used </ufs/ufs/...> correctly.
In the bsd.kmod.mk world, this will let us get rid of some
more symlink hackery in libafs, since the system's '@' symlink
will point to the system headers directly.
Michael Meffie [Thu, 14 Jul 2011 16:02:21 +0000 (12:02 -0400)]
audit: remove uneeded strncpy
In this caller to krb_realms, when no realms names are returned the
number of local realms is correctly set to zero, however the first
local realm buffer is filled with a placeholder string which is
not used. Remove the uneeded strncpy, which also makes this
section of code consistent with afs_is_foreign_ticket().
This section of code is duplicated by afs_is_foreign_ticket() and
should be consolidated in a subsequent patch.
Change-Id: I48f84934e7321769eebaf80c83b2c100fd026a6a
Reviewed-on: http://gerrit.openafs.org/5020 Reviewed-by: Simon Wilkinson <sxw@inf.ed.ac.uk> Tested-by: Simon Wilkinson <sxw@inf.ed.ac.uk> Reviewed-by: Derrick Brashear <shadow@dementia.org> Tested-by: Derrick Brashear <shadow@dementia.org>