malloc() returns a (void *) on all of our current platforms. So,
don't bother casting the return value before assigning it - it's
unecessary noise.
Change-Id: I534d424da13e03d3c0f0de3dddf1dd19088d1659
Reviewed-on: http://gerrit.openafs.org/7458
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
All of our allocators return (void *) values, so there is no need
to cast the returns - doing so is just noise.
Change-Id: I6b1009efbb5034225a4af0e19d03b74c628dfb82
Reviewed-on: http://gerrit.openafs.org/7457
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
calloc returns a (void *) argument. So we don't need to cast its
output before storing it.
Change-Id: Ibdfc61a8a2cf9779a0bfb17ff8ebf1f3bef3ea0e
Reviewed-on: http://gerrit.openafs.org/7456
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
realloc takes, and returns a (void *) argument. So we don't need to
cast these parameters into, or out of, realloc. Doing so is just
noise, so don't bother.
Change-Id: I64e721703536515b2e315e3b033eb2be14f7e18c
Reviewed-on: http://gerrit.openafs.org/7455
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Rather than doing
a = malloc(sizeof(me));
memset(a, 0, sizeof(me));
Just use
a = calloc(1, sizeof(me));
This is simpler, shorter, and removes the potential for the size of
the memset not matching the size of the malloc (or the target of the
memset being wrong!)
Where the size is of the form (n * sizeof(me)), we also use
calloc(n, sizeof(me));
Change-Id: Ia0f75665c1031fd2982eee0e1d8c8ebe23d7fbc0
Reviewed-on: http://gerrit.openafs.org/7454
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
free(3) is defined as:
void free(void *ptr);
so there is no need to cast the pointer argument being past to it to
(char *), (void *), or whatever other randomness happened to be floating
through the author's mind. Remove all such casts, as they are just
noise.
Change-Id: Ib7c8c259d53e9ce74fc486cb0997360044795395
Reviewed-on: http://gerrit.openafs.org/7453
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Instead of allocing a maximal string, and using snprintf to
construct each possible DNS search string, just use asprintf to
construct each string. This greatly simplifies the code, and makes
it much less likely that maths errors can creep in causing buffer
overflows in the future. The downside is that we have more round
trips to the allocator, but that shouldn't matter in this context.
Change-Id: Iae9ab7d45f454c90a937354c71c9ec7fa2c55b69
Reviewed-on: http://gerrit.openafs.org/7452
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Rather than using something along the lines of
strOut = malloc(strlen(strA) + strlen(strB) + strlen(strC) + 1);
strcpy(strOut, strA);
strcat(strOut, strB);
strcat(strOut, strC);
use asprintf for string construction, so we can just write
asprintf(&strOut, "%s%s%s", strA, strB, strC);
roken provides an implementation of asprintf for platforms which are
missing one.
Change-Id: Ieef9f4b65f72260c0d372cdf3865daab98733ad9
Reviewed-on: http://gerrit.openafs.org/7451
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Where we have
newStr = malloc(strlen(oldStr)+1);
strcpy(newStr, oldStr);
replace these with
newStr = strdup(oldStr);
It's shorter, clearer, and gets rid of a load of occurences of strcpy,
which some compilers are now warning is unsafe (although it isn't in
this context)
Get rid of a number of custom duplicate string functions and replace
them with strdup where the behaviour is identical
Change-Id: If800343a7d13b1ba6362d4570a2a324fa3525250
Reviewed-on: http://gerrit.openafs.org/7450
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
A fakestat value of 1 is for -fakestat-all, and 2 is for -fakestat,
not the other way around.
Change-Id: Iedfb7b4a5223c809ace5b5f704a671e8523eb53a
Reviewed-on: http://gerrit.openafs.org/7445
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
cmd_OptionAsInt will return 0 if the requested option is present and
valid.
Change-Id: Ie5154648ccb274b04617dcb8cc397ed3aa3d97e6
Reviewed-on: http://gerrit.openafs.org/7444
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
memcache doesn't make use of fullpn_DCacheFile, fullpn_VolInfoFile,
etc. Do not even try to generate these strings for memcache, since
cacheBaseDir will be NULL, and so this can cause a segfault on some
platforms including Solaris.
Change-Id: I0decdb9a8866272adf500125af7edb03c98e6bdc
Reviewed-on: http://gerrit.openafs.org/7442
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Add some comments to try and help explain the meaning of the
'needvalid' parameter to GetDSlot, added in
1a672914ab.
Change-Id: I4f1c704fa131df07e671f46b1b7575fbf607fce4
Reviewed-on: http://gerrit.openafs.org/7429
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
needvalid will always be 1 for the memory cache -- i.e. the slots are
always valid. see change id I53ea6e99649e4d6d5cbde58929dfcee1d45a3e7b.
Change-Id: Id1294d54cb5f20d226258e5da39fb4d4f782a694
Reviewed-on: http://gerrit.openafs.org/7421
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Alistair Ferguson <alistair.ferguson@mac.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
If an error occurs during convertROtoRW, the volume lock may
not be released.
Change-Id: Ic03af00676de836cade4e39a743b234a0dc9b6cf
Reviewed-on: http://gerrit.openafs.org/7389
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Alistair Ferguson <alistair.ferguson@mac.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
vos convertROtoRW was not checking the return code from
ubik_VL_SetLock().
Change-Id: I651c543f9a0070a9d34d9cca7583437e50e95dc8
Reviewed-on: http://gerrit.openafs.org/7388
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Alistair Ferguson <alistair.ferguson@mac.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Cannot call AFSPerformObjectInvalidate directly because
ObjectInfoCB->Specific.Directory.DirectoryNodeHdr.TreeLock is
held during the sequence
AFSVerifyEntry->AFSValidateDirectoryCache->AFSVerifyDirectoryContent
and AFSPerformObjectInvalidate requires the Fcb->NPFcb->Resource
which must be held prior to the TreeLock.
Change-Id: I337f52e2927c8e5ae2d218867987625c3240a792
Reviewed-on: http://gerrit.openafs.org/7423
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
buf_InsertToRedirQueue, buf_RemoveFromRedirQueue, and
buf_MoveToHeadOfRedirQueue can be passed a NULL cm_scache_t pointer.
If the pointer is NULL (as is the case during buf_Init() processing)
the scp->redirMx must not be obtained or a crash will occur.
Change-Id: I157091afd973a8b4789976c42de253831a2698a3
Reviewed-on: http://gerrit.openafs.org/7422
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Provide consistency between the SMB path parser and the AFS
redirector path processing by using the same constant, MAX_FID_COUNT,
for both. MAX_FID_COUNT is the maximum number of unique file ids
that can exist in a path after all mount points and symlinks have
been expanded. The current value is 512.
Change-Id: Ife1a29ce7c064c986589bc9e2836899864da2f76
Reviewed-on: http://gerrit.openafs.org/7412
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
If there are extents with a non-zero ActiveCount when AFSTearDownExtents()
is executed, it must leave them alone and attached to the File Control
Block. This has implications for its callers, especially AFSCleanupFcb()
since it may be the case that a Cleanup cannot be completed.
The AFSPrimaryVolumeWorker thread must therefore check after calling
AFSCleanupFcb() whether or not the Fcb ExtentCount is zero before
calling AFSRemoveFcb().
Change-Id: I164dbe24d2bfe69aba0fcb5d845f66415d5bb0c3
Reviewed-on: http://gerrit.openafs.org/7406
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
During VNOVOL processing, if the volume is replicated and the
server reference status is "not busy", set the status to busy
and avoid calling cm_SetServerBusyStatus() because that function
mirrors the loop that is already being processed.
Change-Id: I1c92fd02fecc92c3dcd94a33eb87fe5c2fa254ae
Reviewed-on: http://gerrit.openafs.org/7411
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
If the RW volume is listed after the RO convert target in the VLDB,
the code failed to detect that an RW is already present and would
create a second RW volume.
Change-Id: Ia77004214c4d1b18699b5527bc1fc928e8e1143d
Reviewed-on: http://gerrit.openafs.org/7385
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
A crash dump showed that it is possible for a Cleanup
to race with a Read from the ioctl file. Add reference counting
to protect against crashing under such a circumstance.
Change-Id: I5dada2b5855603807b48a191db46ff48043c1997
Reviewed-on: http://gerrit.openafs.org/7405
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Windows Media Player was failing to play media files from
mapped drives if the mapping was to a directory several
levels below \\afs\cellname\. The code to permit SUBST drive
letters to work got in the way during NPGetConnection processing.
Try to get the connection info without the drive substitution
logic. Try again with the drive substitution if the result
is no connection present.
FIXES 130757
Change-Id: I0c2037d1d8f4c6cf82fbff7d4baee995b5124b39
Reviewed-on: http://gerrit.openafs.org/7402
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Fixes a few inconsistencies and bugs in some error messages.
Change-Id: Ic4971c4cc3a3aa3623ee0f13161fd7793d3acb19
Reviewed-on: http://gerrit.openafs.org/7387
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
With this change, we gain the ability to set our command line options
from krb5.conf configuration files. This is only available for tools
which are implemented using the new cmd_OptionAs accessor methods.
Callers should load their configuration file using
cmd_OpenConfigFile("/path/to/config/file.conf");
(an addition to libauth to return a path to a system wide
configuration file will be forthcoming)
and then set their command name (for example, "fileserver", "afsd",
"vos" and so on) using
cmd_SetCommandName("mycommand");
The accessor functions will then populate their return values with
either:
a) The command line options, if specified
b) The contents of the tag matching the option name, in the
[command_subcommand] section of the configuration file, if it
exists
c) The contents of the same tag, in the [command] section of the
configuration file, if it that exists.
d) The contents of the same tag in the [defaults] section of the
configuration file.
Callers can also gain access to the entire configuration file by
calling cmd_RawFile, or to just the section corresponding to their
command line by calling cmd_RawSection. Note that when using the file
directly, it is up to callers to preserve consistency by implementing
similar inheritance rules as the above.
Change-Id: Ic501ab296af3638f961486869af79c9ce47b77b8
Reviewed-on: http://gerrit.openafs.org/7135
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Add additional tests to the libcmd test suite to verify the
behaviour of cmd_OptionPresent and cmd_OptionAsList
Change-Id: I81a235fb5ee87682c72ca942f1341f77be6fda39
Reviewed-on: http://gerrit.openafs.org/7392
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
modify afshelper to just run what it's told instead
of offering fixed operations. this avoids having a setuid
tool around. in spite of apple's suggestion this is correct,
it's actually more dangerous. instead, elevate privilege only
to run a small set of commands, then drop. allow
unlocking of the prefs pane, but make the menu extra prompt
for authentication when needed.
deactivate controls in the prefs pane when locked.
Change-Id: I0e2510efc98605f464e04d26cc8f2ce2bfe116f4
Reviewed-on: http://gerrit.openafs.org/7196
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
For ubik server processes, rx_SetNoJumbo needs to be called before
ubik initialization for it to effect the communication between
dbservers; otherwise, full database transfers may result in Rx
jumbograms on the wire regardless of the jumbo/nojumbo setting. Move
the call to rx_SetNoJumbo to before ubik initialization to avoid this.
Also move the call to rx_SetNoJumbo to immediately after rx_Init* for
all server processes, for consistency. Move similar calls to
rx_SetMaxMTU for the same reason.
Change-Id: Ic79415829601fcfb4e74e72fbf5711d0c32aaa0c
Reviewed-on: http://gerrit.openafs.org/7350
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
They were copied from another command; corrected them.
Change-Id: Ic77f1a91520ec4147e42864438d98942f6a7effc
Reviewed-on: http://gerrit.openafs.org/7305
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Ken Dreyer <ktdreyer@ktdreyer.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
fs newcell works slightly differently on Windows. Document the
differences in the man page.
FIXES 125094
Change-Id: I3fb71ebb28290222069d795762f50a82f3fb6495
Reviewed-on: http://gerrit.openafs.org/6919
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
In attach_volume_header, make sure we free the volume's header if
we're returning an error. We take care of the locks and i/o handles in
the immediately preceding block, but for an actual error we don't get
rid of the header. Do so.
Noticed by Tom Keiser.
Change-Id: I97e61700f644066ac1a0e6b45a67dd62c5397034
Reviewed-on: http://gerrit.openafs.org/7325
Reviewed-by: Tom Keiser <tkeiser@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Add the m4/krb5-config.m4 file, which is required for version 4.4,
to the list of imports.
Change-Id: Ib5d3d0d7be67eaa75f6edc6d030cdb3c47838d3c
Reviewed-on: http://gerrit.openafs.org/7400
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Russ Allbery <rra@stanford.edu>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Instead of bundling our own copies of Russ's C TAP Harness, start using
source pulled from his git repository using the src/external import
mechanism. Note that we are not currently building the floating
point (is_double) portion of the harness.
In the process of doing so, we also upgrade our test harness to the latest
upstream version, 1.11. This is somewhat problematic, as there have been
some significant code changes since the version bundled with OpenAFS.
Work around these by
*) Referencing the basic.h header as <tests/tap/basic.h>, rather than
just <tap/basic.h>, to match the new upstream layout
*) Changing the include path so that the tests/ directory can be
found within it.
Change-Id: I63efbb30248165e5729005b0a791e7eb7afb051d
Reviewed-on: http://gerrit.openafs.org/7374
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Russ Allbery <rra@stanford.edu>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Somehow or another, the file list committed as
098e6f141f is missing the tests/
prefix for a number of object files. Reinstate this prefix.
Change-Id: I2b807bf6fb8e5f136aef571e576c036714280b0c
Reviewed-on: http://gerrit.openafs.org/7398
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Russ Allbery <rra@stanford.edu>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
When the afs redirector is in use, it is possible that "fs memdump"
could be executed while all of the pages in the Windows page cache
are dirty with data that must be purged and flushed to \\afs. In
such a situation it is not safe for afsd_service.exe to hold
global locks such as buf_globalLock, cm_scacheLock, etc. while
performing WriteFile() calls against %TEMP%\afsd_alloc.log if
afsd_alloc.log was opened without the FILE_FLAG_NO_BUFFERING flag.
Doing so can result in a deadlock as it can become impossible for
the Windows page cache to purge data to complete the WriteFile()
as all extent operations block waiting for the global lock to
be cleared.
The correct long term approach would be to use the FILE_FLAG_NO_BUFFERING
flag when opening %TEMP%\afsd_alloc.log. However, this requires that
all writes to the file be performed using buffers that are consistent
with the drive geometry. Such an approach would be incompatible with
the _CrtMemDumpAllObjectsSince() operation and would require a redesign
of the current interfaces. See
http://msdn.microsoft.com/en-us/library/windows/desktop/cc644950(v=vs.85).aspx
for requirements when using non-buffered writes.
The short term fix is to dump the contents without holding the
global locks. This can result in an inconsistent view of the world
but will ensure that deadlocks are avoided. This patchset makes
such a change when the afs redirector is in use.
Change-Id: I6ffc0ff7c80707f16bf132f2dcab7dab5727894d
Reviewed-on: http://gerrit.openafs.org/7391
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
VAttachVolumeByVp_r (specifically attach_check_vop in attach2) already
handles checking for conflicting vol ops, and gives us VOFFLINE
appropriately. We don't need to check again in GetVolume.
Change-Id: Ibb93d423d3c856dd957a2569412a85698180ff8e
Reviewed-on: http://gerrit.openafs.org/7304
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Tom Keiser <tkeiser@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
add float.h to the list of files we import for c-tap-harness from
upstream
Change-Id: I133dd6172bab17ae183cc6fc983f92f19005ba85
Reviewed-on: http://gerrit.openafs.org/7381
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Change the command test so that it uses an enum, rather than #defines
for offsets into the parms array. This is mainly a cosmetic change, but
brings the test suite into line with the way that we're doing stuff in
the "real" code.
Change-Id: Ia9d72e13230edd4fe13af52ba6816cf775693c36
Reviewed-on: http://gerrit.openafs.org/7133
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Tom Keiser <tkeiser@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
attach2/VAttachVolumeByVp_r do not alter the yielded error code
according to specialStatus. So, pay attention to specialStatus after
receiving an error from VAttachVolumeByVp_r, to ensure we respond with
the correct error code.
Change-Id: I59e977dd1f0949f8fe5670c7a52429acbfb7d7e9
Reviewed-on: http://gerrit.openafs.org/7303
Reviewed-by: Tom Keiser <tkeiser@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>