Move the -flag parameter to be the first parameter, to test more of
the positional argument handling.
Change-Id: I637c58e8c76bfc23919f29a1c598084275426773
Reviewed-on: http://gerrit.openafs.org/4710
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <sxw@inf.ed.ac.uk>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
We need to give a NULL pointer for string OUT arguments, so XDR knows
to allocate a new string. Also free the string each time so it gets
set back to NULL.
Change-Id: I1eb0c63dc4019b855a2cbecd9e35393f2fbb0fd7
Reviewed-on: http://gerrit.openafs.org/4708
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Add an accessor function which can return a unsigned int for an
option value.
Change-Id: I33bc9a2618191ca60b95086624100b54efb05ab2
Reviewed-on: http://gerrit.openafs.org/4652
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
If the first parameter of a libcmd syntax is a flag, cmd_Parse was
skipping over positional arguments, since j will be 0 at this point
(the j variable is only used if we're processing an explicit switch).
Effectively revert this area to what it was before
a2f1ca5fd52ac2fb7e68b101bbe3da9878c10474 so such positional parameters
work again.
Also move the j variable to inside the only block in which it is used,
to try and avoid such mistakes in the future.
Change-Id: Ifa52cecf50a3f561c70de351a9ebd026e90eeeab
Reviewed-on: http://gerrit.openafs.org/4711
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
A recent change (commit 80fe111f0044aa7a67215ad92210dc72cb7eb2c0)
to afs_vcache.c contains a call to afs_warn() whose second parameter
contains a "(uintptr_t)" type cast as part of a double type cast.
This presents an issue on some systems, such as OpenBSD, where this
object type is defined in a header that is not presently included.
This change modifies that type cast to instead use the AFS-internal
"(uintptrsz)" type which should provide the same effect.
Note that an earlier version of this patch ateempted to remove the
"offending" type cast as redundant but it was pointed out that some
systems require this kind of cascading type cast when casting pointers
to integers to deal with possible size issues.
Change-Id: Iea81b2be1050a1c929978a99c518d86c6d1f2118
Reviewed-on: http://gerrit.openafs.org/4671
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
Include any command aliases in the output from the -help option
Change-Id: Ifb2ac96d9ba6fc64bffff69bac9480a6b7e8568e
Reviewed-on: http://gerrit.openafs.org/4651
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
On namei fileservers, also print the namei filenames of the volume special
files when the -header flag is given.
Change-Id: I90112f13d0f39348ee3862fdbdb55074e8877108
Reviewed-on: http://gerrit.openafs.org/4696
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Do not print the volumes aux totals prematurely when running
volinfo with the -headers flag on an namei fileserver. Instead
print the aux totals only once after the link table size is found.
Change-Id: I4538e2fc8978530fd2e8593e0b343a2497c7a764
Reviewed-on: http://gerrit.openafs.org/4694
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Print volinfo errors messages to stderr instead of a mix of stdout
and stderr. Print a consistent program name.
Change-Id: Ifadae52d56a75ff7d73d639ff1dd893b1a926a28
Reviewed-on: http://gerrit.openafs.org/4693
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Fix the volume size calculation when volinfo is invoked with
both -sizeOnly and -saveinodes at the same time.
Change-Id: Ifafe6a128918500ac6fd5f9a1e39de2d4aff785d
Reviewed-on: http://gerrit.openafs.org/4691
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Add the namei -filenames option to the volinfo man page.
Note this option as implemented implies the -vnode flag, but for
consistency with the other fields that modify the default mode
output, it is documented to be accompany the -vnode flag.
Change-Id: I7cc5cdf5e74e65ca25ecc086e550a468b803b971
Reviewed-on: http://gerrit.openafs.org/4690
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Fix the logic for checking the presense of the volinfo -filenames
option. The original patch inadvertently added the -filenames
check as an if-else cause to the -orphaned flag check, which
prevents filenames from being printed when listing orphaned
vnodes.
Change-Id: I070d796e7ea9c0f5df9cf92a17eaa4004444d423
Reviewed-on: http://gerrit.openafs.org/4689
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
simplify the logic which can require sleeps in various vcache
resolution paths. instead of the two-pass system we had before,
just guess using the even/odd hack what type a vnode will be.
if a vnode turns out to be a link and thus we are wrong, we
do a fixup later. other callers who "race" with bulkstat
(which is a supported feature, otherwise you'd have to block
callbacks) will also call through a fixup to get the correct
backing vnode type. this is necessary as the KPI doesn't
let us change the type of a vnode after it's been created.
side effect: eliminate many of the ugly cases where we had been
sleeping waiting for a vnode to be finalized even before bulkstat.
Change-Id: Ib888fa5577d48354725ea72305765e4341bc2366
Reviewed-on: http://gerrit.openafs.org/4677
Tested-by: Derrick Brashear <shadow@dementia.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
when we create a vnode using a dynroot fid, we weren't bothering
to update the type from the default (typically VREG); most
dynroot vnodes are actually VDIR...
Change-Id: I1c54e8c2a3c7ffd234f3247d38730062484fec87
Reviewed-on: http://gerrit.openafs.org/4686
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
If our call to mod_install fails for any reason (for example, if the
afs entry is missing from /etc/name_to_sysnum), we may still have set
the sysent structures for setgroups and ioctl to point at libafs code.
So calls to those syscalls will cause a panic, since the code they
point to is no longer loaded.
To avoid this, just reset the sysent entries back to what they were if
we fail to load, just like we do when unloading the module.
Change-Id: Ia0d6691780c749a0f550e640783c093ae45604ac
Reviewed-on: http://gerrit.openafs.org/4685
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
Currently code dealing with changing unixuser structs does not obtain
any locks protecting the contents of the unixuser struct, though some
functions like afs_GetUser have a parameter indicating what type of
lock should be obtained. This can result in the token data for a user
being changed at the same time another thread tries to use the token
data.
To ensure mutual exclusion of such operations, add a lock field to the
unixuser struct, and actually lock it according to the intentions of
the relevant code.
Change-Id: Idd66d72f716b7e7dc08faa31ae43e9a23639bae3
Reviewed-on: http://gerrit.openafs.org/4636
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
afs_NewVolumeByName was using the areq given by the caller for
afs_SetupVolume, which may represent authenticated credentials. Give
afs_SetupVolume &treq instead, which will be anonymous, so we don't
have to deal with rxkad for VL lookups.
Change-Id: Ie990028133173c312d2e5d9de4baa82b99cfdf7d
Reviewed-on: http://gerrit.openafs.org/4666
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Makes all previous -noexecute arguments hidden (still callable)
and replaces them with -dryrun whose help text has been made
common where appropriate instead of the 3 previous ways the
argument was explained.
Change-Id: I0ef3daa88dc771d972131358dc6e8a23ecd5a33b
Reviewed-on: http://gerrit.openafs.org/4678
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
If the DNS SRV lookup is for afs3-prserver or afs3-kaserver,
fallback to a lookup for afs3-vlserver since those services
are traditionally hosted on the same machine as the vlserver.
FIXES 129887
Change-Id: Iec553415cd4f491ea5c32923c4023619bf6320e8
Reviewed-on: http://gerrit.openafs.org/4676
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
It is not safe to protect two 16-bit fields in a structure
with different locks. Switch to using 32-bit fields.
Increment the cm-memmap version number since the data structure
sizes changed and the cache file must be invalidated.
Change-Id: I867b4b85b4fd9fe0083ad9d0559311f1c287513f
Reviewed-on: http://gerrit.openafs.org/4660
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
If krb5_cc_start_get fails when using Heimdal, the cursor
is invalid and it is not safe to pass it into subsequent
functions.
Change-Id: I65193fb63c33ddcbf741c21b40128785404ea920
Reviewed-on: http://gerrit.openafs.org/4658
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
Commit 2578555d7e08131bf2fe4cdd0aa4b32567a76eb2 added vnode length
checks when we create or remove vnodes, but not during Rename and Link
operations (when vnodes are neither created nor destroyed). Add the
check in Rename and Link.
Change-Id: I8008380a2b9e286d2dcdabaed5ceba97909dbb37
Reviewed-on: http://gerrit.openafs.org/4668
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Turn on NAT ping on the Rx connection for the callback channel for
hosts. This should help improve behavior for clients behind NATs and
stateful firewalls, even for clients that predate NAT ping
functionality.
Change-Id: I0f8e801c2225560192de9c09bfa06d0387e29af3
Reviewed-on: http://gerrit.openafs.org/4646
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
removeAddress_r has some code that is identical to the
h_SetupCallbackConn_r function. Call the function instead.
Change-Id: I3416dd1b5c94f0e836c2461771389045994e7152
Reviewed-on: http://gerrit.openafs.org/4645
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
If the DAFS salvager is running in a standalone mode, unlink the
fileserver's fsstate.dat file if any volumes change. Otherwise, volume
data could have changed and the fileserver will retain callback
promises for the data in those volumes until it tries to attach the
volume. This way, callbacks are broken via callback state
reinitialization.
A better solution is to record which volumes have changed, and the
fileserver can break callbacks for them on startup. But this at least
eliminates a regression from non-DAFS behavior.
Change-Id: Ie443e7d43705c3015d21bd3cad1b1e05c88562be
Reviewed-on: http://gerrit.openafs.org/4638
Tested-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
The cmd_OptionAsString function attempts to free the previous value
of the string passed to it. Make sure that we initialise the return
value to NULL before passing it in in the test suite.
Change-Id: I8500d5e6812f4d1655fc50618db472c745604e41
Reviewed-on: http://gerrit.openafs.org/4653
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Currently, a few platforms (linux, linux24, solaris, irix) flush all
vcaches during shutdown. However, they do this before calling
afs_shutdown(), resulting in afs_FlushVCache queueing VCBs and
possibly trying to give the callbacks back to the server.
Instead of this, perform the flushes in afs_shutdown itself, so we do
this after we try to give up all callbacks to all servers, and we do
this while afs_shuttingdown is set, so we don't try to queue VCBs.
This also consolidates some of the duplicated code to flush all
vcaches, and now does this for all platforms.
Change-Id: I69c9e0862972f18ecc29ff709943d9a77f2db0a9
Reviewed-on: http://gerrit.openafs.org/4641
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Commit cee2c677d7de66a510d05978e3b41dcd5d8aca78 caused the cache
manager to give up all callbacks at shutdown. But
76158df491f47de56d1febe1d1d2d17d316c9a74 removed the call to
afs_FlushVCBs in afs_shutdown. Put it back.
Change-Id: I74b815af485482ab83b9115772e4f4221a731f3e
Reviewed-on: http://gerrit.openafs.org/4640
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Our RXAFSCB_InitCallBackState* handler currently write-locks
afs_xserver when it clears the SCAPS_KNOWN flag for the relevant
server. However, the afs_xserver lock is for protecting the global
list and hash table of server structures, and is not necessary to
acquire in order to modify the flags of an individual server struct.
For instance, CkSrv_GetCaps does not acquire any locks to modify the
server flags.
Taking this lock conflicts with a read lock on afs_xserver acquired by
afs_FlushVCBs when it traverses the list of server structures.
afs_FlushVCBs may contact a server that then calls InitCallBackState
on us, causing a deadlock if ICBS waits for the afs_xserver lock.
So, avoid locking afs_xserver in this case, to avoid that deadlock.
Change-Id: Id4dea74ce85726a3da07f738e301600f46059297
Reviewed-on: http://gerrit.openafs.org/4639
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Caught by Lintian in the strings in the butc binary, so I did a global
search for any other occurrences.
Change-Id: I5d5b433e716a62dc43d1c5376841e41d49e29ba5
Reviewed-on: http://gerrit.openafs.org/4657
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Commit 2571b6285d5da8ef62ab38c3a938258ddd7bac4e fixed an issue with
the use of tmpfs as a disk cache and ftruncate() on files in AFS.
But it introduced a problem reading larger files as reported in
RT ticket 129880.
What should be compared against the current cache file size is the
offset into the current chunk, not the overall offset for the whole
file.
FIXES: 129880
Change-Id: I93008c8d0b1d70785b0b8a2e4289a04ac06cbbef
Reviewed-on: http://gerrit.openafs.org/4656
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
rpmbuild --eval '%undefine dist' wasn't sticking on redhat 5.x. I think
the correct way to undefine this is to --define 'dist %undefined'
Some redhat 5.x installs have %dist defined depending on what else has been
installed.
Change-Id: I9ad6854a337c2085bb2db5e5f98e7d2f9889c4e4
Reviewed-on: http://gerrit.openafs.org/4643
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <sxw@inf.ed.ac.uk>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Some compilers complain that _inode is used uninitialised here.
Since this test requires -Werror, it causes the test to fail
and our permission op to be used in RCU mode, leading to lockups.
Initialise it to make the compilers happy.
Fixes a lockup seen on kernels 2.6.38+ on Gentoo and Debian.
Change-Id: Id6325e3a5a918906d547d241a39de777fb394fdc
Reviewed-on: http://gerrit.openafs.org/4654
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
we get network byte order addresses from rx_getAllAddr; swap back
to host order.
Change-Id: Id0c5e70399422593c574958f905984c9edf8e6d4
Reviewed-on: http://gerrit.openafs.org/4644
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
In the KFW_AFS library, always try afs/cell@USER-REALM
first, even when KFW_AFS_klog() is called with an explicit
realm mapping for the cell. An afs service principal from
the user's realm is always preferred. No cross realm and
if the realm is AD, the ability to avoid the inclusion of
a PAC.
Change-Id: Ia29085e03d7c8a7c05e0c8d7991bc48b780b84fa
Reviewed-on: http://gerrit.openafs.org/4633
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Do not reject dotted principal names if the registry
configuration states that they should be accepted.
Change-Id: I675bec085f61ae2f5dc1cfd93a811655f87e0577
Reviewed-on: http://gerrit.openafs.org/4632
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
afs_GetCapabilities gets a user reference for the conn for the
GetCapabilities call. Put the ref back so we don't leak refs.
Change-Id: I46304ea13c3d78216641f468718b23b665d046ff
Reviewed-on: http://gerrit.openafs.org/4626
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
When we get a reference to an afs_conn with afs_Conn and its variants,
we assume we can use the tc->id rx connection without holding any
locks. However, if tc->forceConnectFS gets set, the tc->id connection
can be destroyed and recreated out from under us. So, to avoid using a
possibly freed rx connection, grab a reference to the rx connection at
the same time as we grab a reference to the afs conn. And also put
back the same reference with afs_PutConn.
Change-Id: I442886ee89c6f3fa609e47261317e647e124eecc
Reviewed-on: http://gerrit.openafs.org/4625
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
The environment variable CYGWIN (starting with cygwin 1.7.1) is
now used by CYGWIN to set configuration parameters for the cygwin
runtime library. OpenAFS used it to indicate the location of the
Cygwin install directory. Since there is a conflict, rename CYGWIN
to CYGWINDIR.
Change-Id: I98f6a7095ede4c6a91dd71d48312b0d1a55b8091
Reviewed-on: http://gerrit.openafs.org/4629
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
AFS_LS_DOWN was actually checking up servers, and AFS_LS_UP was
checking down servers. Fix the handling of the 'adown' flag so we do
the right thing. Also make afs_FlushVCBs use the symbolic name for
adown.
Change-Id: I601faf1bb712a2f76f0bb2447530af38111a71fd
Reviewed-on: http://gerrit.openafs.org/4624
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>