net-fs/openafs: fix designated_init build error

1.8.13-r2
1.8.13.1-r1
1.8.13.2-r1

Closes: https://bugs.gentoo.org/949491
Signed-off-by: Cheyenne Wills <cwills@witznd.net>
Closes: https://github.com/gentoo/gentoo/pull/40410
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Cheyenne Wills
2025-03-20 00:05:03 +00:00
committed by Sam James
parent 03e373de31
commit 1a6aca0ff0
5 changed files with 1606 additions and 0 deletions
@@ -0,0 +1,354 @@
From 9e612ba7bf1ccea8158ae38b5d687d8d78e1630e Mon Sep 17 00:00:00 2001
From: Cheyenne Wills <cwills@sinenomine.net>
Date: Wed, 26 Feb 2025 08:03:18 -0700
Subject: [PATCH 1/2] Convert HAVE_STRUCT_LABEL_SUPPORT to AFS_STRUCT_INIT
The OpenAFS coding style allows the use of designated initializers for
structs, however not all supported platforms have compilers that support
it.
The preprocessor define HAVE_STRUCT_LABEL_SUPPORT has been available for
use so structure initialization can be set up to support compilers that
do have designated initializers support.
The typical use is:
struct foo x = {
#ifndef HAVE_STRUCT_LABEL_SUPPORT
val1,
val2,
...
#else
.mem1 = val1,
.mem2 = val2,
...
#endif
};
This results in extra lines of code where errors can easily be
introduced.
Create a macro, AFS_STRUCT_INIT, that uses designated initializers when
available, so the above example would be:
struct foo x = {
AFS_STRUCT_INIT(.mem1, val1),
AFS_STRUCT_INIT(.mem2, val2),
...
};
Convert the initialization of structures that are using the
HAVE_STRUCT_LABEL_SUPPORT define to use AFS_STRUCT_INIT.
Note, there is still a requirement that the order of initializers match
the order of the elements within the structure, but it should be easier
to verify that the initializers are in the proper order.
Use a consistent alignment, and add trailing comma on the last
element.
There are no functional changes made by this commit.
Reviewed-on: https://gerrit.openafs.org/16289
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
(cherry picked from commit 7c28b99490b75475ed9130526c536ae0e354e064)
Change-Id: I8faa4b497f2962bdd0a4ecb559e8b9288fd5c796
---
src/afs/afs_dcache.c | 66 ++++++++++++----------------------------
src/afs/afs_fetchstore.c | 54 ++++++++++----------------------
src/config/stds.h | 6 ++++
src/rx/xdr_len.c | 28 +++++------------
src/rx/xdr_mem.c | 28 +++++------------
src/rx/xdr_rx.c | 28 +++++------------
6 files changed, 66 insertions(+), 144 deletions(-)
diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c
index 35fd5947325d..e41ba8ff3a8e 100644
--- a/src/afs/afs_dcache.c
+++ b/src/afs/afs_dcache.c
@@ -104,55 +104,29 @@ afs_int32 afs_dcentries; /*!< In-memory dcache entries */
int dcacheDisabled = 0;
struct afs_cacheOps afs_UfsCacheOps = {
-#ifndef HAVE_STRUCT_LABEL_SUPPORT
- osi_UFSOpen,
- osi_UFSTruncate,
- afs_osi_Read,
- afs_osi_Write,
- osi_UFSClose,
- afs_UFSReadUIO,
- afs_UFSWriteUIO,
- afs_UFSGetDSlot,
- afs_UFSGetVolSlot,
- afs_UFSHandleLink,
-#else
- .open = osi_UFSOpen,
- .truncate = osi_UFSTruncate,
- .fread = afs_osi_Read,
- .fwrite = afs_osi_Write,
- .close = osi_UFSClose,
- .vreadUIO = afs_UFSReadUIO,
- .vwriteUIO = afs_UFSWriteUIO,
- .GetDSlot = afs_UFSGetDSlot,
- .GetVolSlot = afs_UFSGetVolSlot,
- .HandleLink = afs_UFSHandleLink,
-#endif
+ AFS_STRUCT_INIT(.open, osi_UFSOpen),
+ AFS_STRUCT_INIT(.truncate, osi_UFSTruncate),
+ AFS_STRUCT_INIT(.fread, afs_osi_Read),
+ AFS_STRUCT_INIT(.fwrite, afs_osi_Write),
+ AFS_STRUCT_INIT(.close, osi_UFSClose),
+ AFS_STRUCT_INIT(.vreadUIO, afs_UFSReadUIO),
+ AFS_STRUCT_INIT(.vwriteUIO, afs_UFSWriteUIO),
+ AFS_STRUCT_INIT(.GetDSlot, afs_UFSGetDSlot),
+ AFS_STRUCT_INIT(.GetVolSlot, afs_UFSGetVolSlot),
+ AFS_STRUCT_INIT(.HandleLink, afs_UFSHandleLink),
};
struct afs_cacheOps afs_MemCacheOps = {
-#ifndef HAVE_STRUCT_LABEL_SUPPORT
- afs_MemCacheOpen,
- afs_MemCacheTruncate,
- afs_MemReadBlk,
- afs_MemWriteBlk,
- afs_MemCacheClose,
- afs_MemReadUIO,
- afs_MemWriteUIO,
- afs_MemGetDSlot,
- afs_MemGetVolSlot,
- afs_MemHandleLink,
-#else
- .open = afs_MemCacheOpen,
- .truncate = afs_MemCacheTruncate,
- .fread = afs_MemReadBlk,
- .fwrite = afs_MemWriteBlk,
- .close = afs_MemCacheClose,
- .vreadUIO = afs_MemReadUIO,
- .vwriteUIO = afs_MemWriteUIO,
- .GetDSlot = afs_MemGetDSlot,
- .GetVolSlot = afs_MemGetVolSlot,
- .HandleLink = afs_MemHandleLink,
-#endif
+ AFS_STRUCT_INIT(.open, afs_MemCacheOpen),
+ AFS_STRUCT_INIT(.truncate, afs_MemCacheTruncate),
+ AFS_STRUCT_INIT(.fread, afs_MemReadBlk),
+ AFS_STRUCT_INIT(.fwrite, afs_MemWriteBlk),
+ AFS_STRUCT_INIT(.close, afs_MemCacheClose),
+ AFS_STRUCT_INIT(.vreadUIO, afs_MemReadUIO),
+ AFS_STRUCT_INIT(.vwriteUIO, afs_MemWriteUIO),
+ AFS_STRUCT_INIT(.GetDSlot, afs_MemGetDSlot),
+ AFS_STRUCT_INIT(.GetVolSlot, afs_MemGetVolSlot),
+ AFS_STRUCT_INIT(.HandleLink, afs_MemHandleLink),
};
int cacheDiskType; /*Type of backing disk for cache */
diff --git a/src/afs/afs_fetchstore.c b/src/afs/afs_fetchstore.c
index 97d0671811dc..5baf371a2c6a 100644
--- a/src/afs/afs_fetchstore.c
+++ b/src/afs/afs_fetchstore.c
@@ -309,48 +309,26 @@ afs_GenericStoreProc(struct storeOps *ops, void *rock,
static
struct storeOps rxfs_storeUfsOps = {
-#ifndef HAVE_STRUCT_LABEL_SUPPORT
- rxfs_storeUfsPrepare,
- rxfs_storeUfsRead,
- rxfs_storeUfsWrite,
- rxfs_storeStatus,
- rxfs_storePadd,
- rxfs_storeClose,
- rxfs_storeDestroy,
- afs_GenericStoreProc
-#else
- .prepare = rxfs_storeUfsPrepare,
- .read = rxfs_storeUfsRead,
- .write = rxfs_storeUfsWrite,
- .status = rxfs_storeStatus,
- .padd = rxfs_storePadd,
- .close = rxfs_storeClose,
- .destroy = rxfs_storeDestroy,
- .storeproc = afs_GenericStoreProc
-#endif
+ AFS_STRUCT_INIT(.prepare, rxfs_storeUfsPrepare),
+ AFS_STRUCT_INIT(.read, rxfs_storeUfsRead),
+ AFS_STRUCT_INIT(.write, rxfs_storeUfsWrite),
+ AFS_STRUCT_INIT(.status, rxfs_storeStatus),
+ AFS_STRUCT_INIT(.padd, rxfs_storePadd),
+ AFS_STRUCT_INIT(.close, rxfs_storeClose),
+ AFS_STRUCT_INIT(.destroy, rxfs_storeDestroy),
+ AFS_STRUCT_INIT(.storeproc, afs_GenericStoreProc),
};
static
struct storeOps rxfs_storeMemOps = {
-#ifndef HAVE_STRUCT_LABEL_SUPPORT
- rxfs_storeMemPrepare,
- rxfs_storeMemRead,
- rxfs_storeMemWrite,
- rxfs_storeStatus,
- rxfs_storePadd,
- rxfs_storeClose,
- rxfs_storeDestroy,
- afs_GenericStoreProc
-#else
- .prepare = rxfs_storeMemPrepare,
- .read = rxfs_storeMemRead,
- .write = rxfs_storeMemWrite,
- .status = rxfs_storeStatus,
- .padd = rxfs_storePadd,
- .close = rxfs_storeClose,
- .destroy = rxfs_storeDestroy,
- .storeproc = afs_GenericStoreProc
-#endif
+ AFS_STRUCT_INIT(.prepare, rxfs_storeMemPrepare),
+ AFS_STRUCT_INIT(.read, rxfs_storeMemRead),
+ AFS_STRUCT_INIT(.write, rxfs_storeMemWrite),
+ AFS_STRUCT_INIT(.status, rxfs_storeStatus),
+ AFS_STRUCT_INIT(.padd, rxfs_storePadd),
+ AFS_STRUCT_INIT(.close, rxfs_storeClose),
+ AFS_STRUCT_INIT(.destroy, rxfs_storeDestroy),
+ AFS_STRUCT_INIT(.storeproc, afs_GenericStoreProc),
};
static afs_int32
diff --git a/src/config/stds.h b/src/config/stds.h
index 8ae68343458b..ae030149f6d2 100644
--- a/src/config/stds.h
+++ b/src/config/stds.h
@@ -305,6 +305,12 @@ hdr_static_inline(unsigned long long) afs_printable_uint64_lu(afs_uint64 d) { re
# define AFS_FALLTHROUGH do {} while(0)
#endif
+#if defined(HAVE_STRUCT_LABEL_SUPPORT)
+# define AFS_STRUCT_INIT(member, value) member = (value)
+#else
+# define AFS_STRUCT_INIT(member, value) (value)
+#endif
+
/*
* Conditionally remove unreached statements under Solaris Studio.
*/
diff --git a/src/rx/xdr_len.c b/src/rx/xdr_len.c
index 5de15d010d62..9f9fe1ca92ac 100644
--- a/src/rx/xdr_len.c
+++ b/src/rx/xdr_len.c
@@ -84,26 +84,14 @@ xdrlen_inline(XDR *xdrs, u_int len)
}
static struct xdr_ops xdrlen_ops = {
-#ifndef HAVE_STRUCT_LABEL_SUPPORT
- /* Windows does not support labeled assigments */
- xdrlen_getint32, /* not supported */
- xdrlen_putint32, /* serialize an afs_int32 */
- xdrlen_getbytes, /* not supported */
- xdrlen_putbytes, /* serialize counted bytes */
- xdrlen_getpos, /* get offset in the stream */
- xdrlen_setpos, /* set offset in the stream */
- xdrlen_inline, /* not supported */
- xdrlen_destroy, /* destroy stream */
-#else
- .x_getint32 = xdrlen_getint32,
- .x_putint32 = xdrlen_putint32,
- .x_getbytes = xdrlen_getbytes,
- .x_putbytes = xdrlen_putbytes,
- .x_getpostn = xdrlen_getpos,
- .x_setpostn = xdrlen_setpos,
- .x_inline = xdrlen_inline,
- .x_destroy = xdrlen_destroy
-#endif
+ AFS_STRUCT_INIT(.x_getint32, xdrlen_getint32), /* not supported */
+ AFS_STRUCT_INIT(.x_putint32, xdrlen_putint32), /* serialize an afs_int32 */
+ AFS_STRUCT_INIT(.x_getbytes, xdrlen_getbytes), /* not supported */
+ AFS_STRUCT_INIT(.x_putbytes, xdrlen_putbytes), /* serialize counted bytes */
+ AFS_STRUCT_INIT(.x_getpostn, xdrlen_getpos), /* get offset in the stream */
+ AFS_STRUCT_INIT(.x_setpostn, xdrlen_setpos), /* set offset in the stream */
+ AFS_STRUCT_INIT(.x_inline, xdrlen_inline), /* not supported */
+ AFS_STRUCT_INIT(.x_destroy, xdrlen_destroy), /* destroy stream */
};
/**
diff --git a/src/rx/xdr_mem.c b/src/rx/xdr_mem.c
index ae849f521bf6..bd6720505edb 100644
--- a/src/rx/xdr_mem.c
+++ b/src/rx/xdr_mem.c
@@ -59,26 +59,14 @@ static afs_int32 *xdrmem_inline(XDR *, u_int);
static void xdrmem_destroy(XDR *);
static struct xdr_ops xdrmem_ops = {
-#ifndef HAVE_STRUCT_LABEL_SUPPORT
- /* Windows does not support labeled assigments */
- xdrmem_getint32, /* deserialize an afs_int32 */
- xdrmem_putint32, /* serialize an afs_int32 */
- xdrmem_getbytes, /* deserialize counted bytes */
- xdrmem_putbytes, /* serialize counted bytes */
- xdrmem_getpos, /* get offset in the stream: not supported. */
- xdrmem_setpos, /* set offset in the stream: not supported. */
- xdrmem_inline, /* prime stream for inline macros */
- xdrmem_destroy, /* destroy stream */
-#else
- .x_getint32 = xdrmem_getint32,
- .x_putint32 = xdrmem_putint32,
- .x_getbytes = xdrmem_getbytes,
- .x_putbytes = xdrmem_putbytes,
- .x_getpostn = xdrmem_getpos,
- .x_setpostn = xdrmem_setpos,
- .x_inline = xdrmem_inline,
- .x_destroy = xdrmem_destroy
-#endif
+ AFS_STRUCT_INIT(.x_getint32, xdrmem_getint32), /* deserialize an afs_int32 */
+ AFS_STRUCT_INIT(.x_putint32, xdrmem_putint32), /* serialize an afs_int32 */
+ AFS_STRUCT_INIT(.x_getbytes, xdrmem_getbytes), /* deserialize counted bytes */
+ AFS_STRUCT_INIT(.x_putbytes, xdrmem_putbytes), /* serialize counted bytes */
+ AFS_STRUCT_INIT(.x_getpostn, xdrmem_getpos), /* get offset in the stream: not supported. */
+ AFS_STRUCT_INIT(.x_setpostn, xdrmem_setpos), /* set offset in the stream: not supported. */
+ AFS_STRUCT_INIT(.x_inline, xdrmem_inline), /* prime stream for inline macros */
+ AFS_STRUCT_INIT(.x_destroy, xdrmem_destroy), /* destroy stream */
};
/*
diff --git a/src/rx/xdr_rx.c b/src/rx/xdr_rx.c
index 62fbed331b02..34e2b4d75efe 100644
--- a/src/rx/xdr_rx.c
+++ b/src/rx/xdr_rx.c
@@ -49,26 +49,14 @@ static afs_int32 *xdrrx_inline(XDR *axdrs, u_int len);
* Ops vector for stdio type XDR
*/
static struct xdr_ops xdrrx_ops = {
-#ifndef HAVE_STRUCT_LABEL_SUPPORT
- /* Windows does not support labeled assigments */
- xdrrx_getint32, /* deserialize an afs_int32 */
- xdrrx_putint32, /* serialize an afs_int32 */
- xdrrx_getbytes, /* deserialize counted bytes */
- xdrrx_putbytes, /* serialize counted bytes */
- NULL, /* get offset in the stream: not supported. */
- NULL, /* set offset in the stream: not supported. */
- xdrrx_inline, /* prime stream for inline macros */
- NULL, /* destroy stream */
-#else
- .x_getint32 = xdrrx_getint32, /* deserialize an afs_int32 */
- .x_putint32 = xdrrx_putint32, /* serialize an afs_int32 */
- .x_getbytes = xdrrx_getbytes, /* deserialize counted bytes */
- .x_putbytes = xdrrx_putbytes, /* serialize counted bytes */
- .x_getpostn = NULL, /* get offset in the stream: not supported. */
- .x_setpostn = NULL, /* set offset in the stream: not supported. */
- .x_inline = xdrrx_inline, /* prime stream for inline macros */
- .x_destroy = NULL, /* destroy stream */
-#endif
+ AFS_STRUCT_INIT(.x_getint32, xdrrx_getint32), /* deserialize an afs_int32 */
+ AFS_STRUCT_INIT(.x_putint32, xdrrx_putint32), /* serialize an afs_int32 */
+ AFS_STRUCT_INIT(.x_getbytes, xdrrx_getbytes), /* deserialize counted bytes */
+ AFS_STRUCT_INIT(.x_putbytes, xdrrx_putbytes), /* serialize counted bytes */
+ AFS_STRUCT_INIT(.x_getpostn, NULL), /* get offset in the stream: not supported. */
+ AFS_STRUCT_INIT(.x_setpostn, NULL), /* set offset in the stream: not supported. */
+ AFS_STRUCT_INIT(.x_inline, xdrrx_inline), /* prime stream for inline macros */
+ AFS_STRUCT_INIT(.x_destroy, NULL), /* destroy stream */
};
/*
--
2.45.3
@@ -0,0 +1,215 @@
From ed1e72e2a3aecd894ca1a029996ef70846e30781 Mon Sep 17 00:00:00 2001
From: Cheyenne Wills <cwills@sinenomine.net>
Date: Tue, 25 Feb 2025 20:09:12 -0700
Subject: [PATCH 2/2] afs: Init structures via designated initializers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When the Linux kernel is configured with CONFIG_RANDSTRUCT=y, the
following error occurs when building the openafs kernel module:
src/libafs/MODLOAD-6.12.0-SP/rand-timer-kernel.c:46:5: error: positional initialization of field in ‘struct’ declared with ‘designated_init’ attribute [-Werror=designated-init]
46 | timer_seed,
| ^~~~~~~~~~
When the Linux kernel is configured with CONFIG_RANDSTRUCT=y, the Linux
build uses a Linux kernel-specific GCC plugin
(scripts/gcc-plugins/randomize_layout_plugin.c) that analyzes structures
and will add the designated_init attribute to any structure that is
determined to be a "pure operations struct" (i.e. contains only function
pointers or nested pure ops structs/unions). This is done so the plugin
can then randomize the layout. This causes some of our structures to be
flagged with the designated_init attribute, which triggers
-Werror=designated-init when we don't use designated initializers.
Within the Linux specific directory, src/afs/LINUX, the code already
uses designated initializers, however some of the shared code within
src/afs or that is included in the build for the kernel module still use
positional initialization when initializing pure operations structures.
Update the shared code that is used when building the Linux kernel
module to use designated initializers via the AFS_STRUCT_INIT macro.
Use a consistent alignment, and add trailing comma on the last
element, change 0 to NULL where applicable.
There are no functional changes within this commit.
Note: For consistency, all the initializers for rx_securityOps are being
updated even though not all of the files are part of the Linux kernel
module (e.g. rxkad_server.c).
Note: This error was discovered by an automated process that is used
by the Gentoo organization to test building packages with a hardened
Linux kernel.
Reviewed-on: https://gerrit.openafs.org/16290
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: Andrew Deason <adeason@sinenomine.net>
(cherry picked from commit e94c183faef42e5ffe85c157ede008f2817bdefd)
[cwills@sinenomine.net changes to rxgk not applicable to 1.8.x]
Change-Id: I56ebb7d34718eef6c5bfbba98e3fb4e350a5129f
---
src/afs/afs_fetchstore.c | 20 ++++++++---------
src/crypto/hcrypto/kernel/rand-timer.c | 14 ++++++------
src/rxkad/rxkad_client.c | 30 +++++++++++++-------------
src/rxkad/rxkad_server.c | 30 +++++++++++++-------------
4 files changed, 47 insertions(+), 47 deletions(-)
diff --git a/src/afs/afs_fetchstore.c b/src/afs/afs_fetchstore.c
index 5baf371a2c6a..5b9e08c3fdec 100644
--- a/src/afs/afs_fetchstore.c
+++ b/src/afs/afs_fetchstore.c
@@ -844,20 +844,20 @@ rxfs_fetchMore(void *r, afs_int32 *length, afs_uint32 *moredata)
static
struct fetchOps rxfs_fetchUfsOps = {
- rxfs_fetchMore,
- rxfs_fetchUfsRead,
- rxfs_fetchUfsWrite,
- rxfs_fetchClose,
- rxfs_fetchDestroy
+ AFS_STRUCT_INIT(.more, rxfs_fetchMore),
+ AFS_STRUCT_INIT(.read, rxfs_fetchUfsRead),
+ AFS_STRUCT_INIT(.write, rxfs_fetchUfsWrite),
+ AFS_STRUCT_INIT(.close, rxfs_fetchClose),
+ AFS_STRUCT_INIT(.destroy, rxfs_fetchDestroy),
};
static
struct fetchOps rxfs_fetchMemOps = {
- rxfs_fetchMore,
- rxfs_fetchMemRead,
- rxfs_fetchMemWrite,
- rxfs_fetchClose,
- rxfs_fetchDestroy
+ AFS_STRUCT_INIT(.more, rxfs_fetchMore),
+ AFS_STRUCT_INIT(.read, rxfs_fetchMemRead),
+ AFS_STRUCT_INIT(.write, rxfs_fetchMemWrite),
+ AFS_STRUCT_INIT(.close, rxfs_fetchClose),
+ AFS_STRUCT_INIT(.destroy, rxfs_fetchDestroy),
};
static afs_int32
diff --git a/src/crypto/hcrypto/kernel/rand-timer.c b/src/crypto/hcrypto/kernel/rand-timer.c
index 3a7023555b67..6ef71737cdeb 100644
--- a/src/crypto/hcrypto/kernel/rand-timer.c
+++ b/src/crypto/hcrypto/kernel/rand-timer.c
@@ -5,7 +5,7 @@
* Contains no copyrightable content.
*/
#include <config.h>
-
+#include <stds.h>
#include <rand.h>
#include "randi.h"
@@ -43,12 +43,12 @@ timer_status(void)
}
const RAND_METHOD hc_rand_timer_method = {
- timer_seed,
- timer_bytes,
- timer_cleanup,
- timer_add,
- timer_pseudorand,
- timer_status
+ AFS_STRUCT_INIT(.seed, timer_seed),
+ AFS_STRUCT_INIT(.bytes, timer_bytes),
+ AFS_STRUCT_INIT(.cleanup, timer_cleanup),
+ AFS_STRUCT_INIT(.add, timer_add),
+ AFS_STRUCT_INIT(.pseudorand, timer_pseudorand),
+ AFS_STRUCT_INIT(.status, timer_status),
};
const RAND_METHOD *
diff --git a/src/rxkad/rxkad_client.c b/src/rxkad/rxkad_client.c
index 1f760b8c0e66..79ea0cf586b3 100644
--- a/src/rxkad/rxkad_client.c
+++ b/src/rxkad/rxkad_client.c
@@ -50,21 +50,21 @@
#endif /* max */
static struct rx_securityOps rxkad_client_ops = {
- rxkad_Close,
- rxkad_NewConnection, /* every new connection */
- rxkad_PreparePacket, /* once per packet creation */
- 0, /* send packet (once per retrans.) */
- 0,
- 0,
- 0,
- rxkad_GetResponse, /* respond to challenge packet */
- 0,
- rxkad_CheckPacket, /* check data packet */
- rxkad_DestroyConnection,
- rxkad_GetStats,
- 0,
- 0,
- 0,
+ AFS_STRUCT_INIT(.op_Close, rxkad_Close),
+ AFS_STRUCT_INIT(.op_NewConnection, rxkad_NewConnection), /* every new connection */
+ AFS_STRUCT_INIT(.op_PreparePacket, rxkad_PreparePacket), /* once per packet creation */
+ AFS_STRUCT_INIT(.op_SendPacket, NULL), /* send packet (once per retrans.) */
+ AFS_STRUCT_INIT(.op_CheckAuthentication, NULL),
+ AFS_STRUCT_INIT(.op_CreateChallenge, NULL),
+ AFS_STRUCT_INIT(.op_GetChallenge, NULL),
+ AFS_STRUCT_INIT(.op_GetResponse, rxkad_GetResponse), /* respond to challenge packet */
+ AFS_STRUCT_INIT(.op_CheckResponse, NULL),
+ AFS_STRUCT_INIT(.op_CheckPacket, rxkad_CheckPacket), /* check data packet */
+ AFS_STRUCT_INIT(.op_DestroyConnection, rxkad_DestroyConnection),
+ AFS_STRUCT_INIT(.op_GetStats, rxkad_GetStats),
+ AFS_STRUCT_INIT(.op_SetConfiguration, NULL),
+ AFS_STRUCT_INIT(.op_Spare2, NULL),
+ AFS_STRUCT_INIT(.op_Spare3, NULL),
};
/* Allocate a new client security object. Called with the encryption level,
diff --git a/src/rxkad/rxkad_server.c b/src/rxkad/rxkad_server.c
index 07e806bcdf36..766904cea562 100644
--- a/src/rxkad/rxkad_server.c
+++ b/src/rxkad/rxkad_server.c
@@ -43,21 +43,21 @@ afs_int32(*rxkad_AlternateTicketDecoder) (afs_int32, char *, afs_int32,
afs_uint32 *);
static struct rx_securityOps rxkad_server_ops = {
- rxkad_Close,
- rxkad_NewConnection,
- rxkad_PreparePacket, /* once per packet creation */
- 0, /* send packet (once per retrans) */
- rxkad_CheckAuthentication,
- rxkad_CreateChallenge,
- rxkad_GetChallenge,
- 0,
- rxkad_CheckResponse,
- rxkad_CheckPacket, /* check data packet */
- rxkad_DestroyConnection,
- rxkad_GetStats,
- rxkad_SetConfiguration,
- 0, /* spare 2 */
- 0, /* spare 3 */
+ AFS_STRUCT_INIT(.op_Close, rxkad_Close),
+ AFS_STRUCT_INIT(.op_NewConnection, rxkad_NewConnection),
+ AFS_STRUCT_INIT(.op_PreparePacket, rxkad_PreparePacket), /* once per packet creation */
+ AFS_STRUCT_INIT(.op_SendPacket, NULL), /* send packet (once per retrans) */
+ AFS_STRUCT_INIT(.op_CheckAuthentication, rxkad_CheckAuthentication),
+ AFS_STRUCT_INIT(.op_CreateChallenge, rxkad_CreateChallenge),
+ AFS_STRUCT_INIT(.op_GetChallenge, rxkad_GetChallenge),
+ AFS_STRUCT_INIT(.op_GetResponse, NULL),
+ AFS_STRUCT_INIT(.op_CheckResponse, rxkad_CheckResponse),
+ AFS_STRUCT_INIT(.op_CheckPacket, rxkad_CheckPacket), /* check data packet */
+ AFS_STRUCT_INIT(.op_DestroyConnection, rxkad_DestroyConnection),
+ AFS_STRUCT_INIT(.op_GetStats, rxkad_GetStats),
+ AFS_STRUCT_INIT(.op_SetConfiguration, rxkad_SetConfiguration),
+ AFS_STRUCT_INIT(.op_Spare2, NULL), /* spare 2 */
+ AFS_STRUCT_INIT(.op_Spare3, NULL), /* spare 3 */
};
extern afs_uint32 rx_MyMaxSendSize;
--
2.45.3
+341
View File
@@ -0,0 +1,341 @@
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
MODULES_OPTIONAL_IUSE="modules"
inherit autotools linux-mod-r1 flag-o-matic pam systemd tmpfiles toolchain-funcs
MY_PV=${PV/_/}
MY_P="${PN}-${MY_PV}"
KERNEL_LIMIT=6.11
DESCRIPTION="The OpenAFS distributed file system"
HOMEPAGE="https://www.openafs.org/"
# We always d/l the doc tarball as man pages are not USE=doc material
[[ ${PV} == *_pre* ]] && MY_PRE="candidate/" || MY_PRE=""
SRC_URI="
https://openafs.org/dl/openafs/${MY_PRE}${MY_PV}/${MY_P}-src.tar.bz2
https://openafs.org/dl/openafs/${MY_PRE}${MY_PV}/${MY_P}-doc.tar.bz2
"
S="${WORKDIR}/${MY_P}"
LICENSE="IBM BSD openafs-krb5-a APSL-2"
SLOT="0"
KEYWORDS="~amd64 -riscv ~sparc ~x86 ~amd64-linux ~x86-linux"
IUSE="apidoc bitmap-later debug doc fuse kauth kerberos +modules +namei
ncurses perl +pthreaded-ubik selinux +supergroups tsm ubik-read-while-write"
BDEPEND="
dev-lang/perl
app-alternatives/lex
app-alternatives/yacc
apidoc? (
app-text/doxygen[dot]
media-gfx/graphviz
)
doc? (
dev-libs/libxslt
|| (
>=dev-java/fop-2.10-r1:0
app-text/dblatex
app-text/docbook-sgml-utils[jadetex]
)
)
perl? ( dev-lang/swig )"
DEPEND="
virtual/libcrypt:=
virtual/libintl
amd64? ( tsm? ( app-backup/tsm ) )
doc? (
app-text/docbook-xsl-stylesheets
app-text/docbook-xml-dtd:4.3
)
fuse? ( sys-fs/fuse:0= )
kauth? ( sys-libs/pam )
kerberos? ( virtual/krb5 )
ncurses? ( sys-libs/ncurses:0= )"
RDEPEND="
${DEPEND}
selinux? ( sec-policy/selinux-afs )"
PATCHES=(
"${FILESDIR}"/0001-autoconf-use-AC_CHECK_TOOL-for-as-and-ld.patch
"${FILESDIR}"/0002-pam-paths.patch
"${FILESDIR}"/0003-fbsd.patch
"${FILESDIR}"/0004-sparc.patch
"${FILESDIR}"/0005-uname.patch
"${FILESDIR}"/0006-resolv.patch
"${FILESDIR}"/0007-afsauthent-symbols.patch
"${FILESDIR}"/0008-flags.patch
"${FILESDIR}"/0009-docbook2pdf.patch
"${FILESDIR}"/0010-libperl.patch
"${FILESDIR}"/0011-xbsa.patch
"${FILESDIR}"/0012-xml-dtd.patch
"${FILESDIR}"/0013-kernel-cc-ld.patch
"${FILESDIR}"/0014-upstream-struct-init.patch
"${FILESDIR}"/0015-upstream-struct-desiginated-init.patch
)
CONFIG_CHECK="~!AFS_FS KEYS"
ERROR_AFS_FS="OpenAFS conflicts with the in-kernel AFS-support. Make sure not to load both at the same time!"
ERROR_KEYS="OpenAFS needs CONFIG_KEYS option enabled"
pkg_pretend() {
if use modules && use kernel_linux && kernel_is -ge ${KERNEL_LIMIT/\./ } ; then
ewarn "Gentoo supports kernels which are supported by OpenAFS"
ewarn "which are limited to the kernel versions: < ${KERNEL_LIMIT}"
ewarn ""
ewarn "You are free to utilize eapply_user to provide whatever"
ewarn "support you feel is appropriate, but will not receive"
ewarn "support as a result of those changes."
ewarn ""
ewarn "Please do not file a bug report about this."
ewarn ""
ewarn "Alternatively, you may:"
ewarn "1. Use OpenAFS FUSE client, build OpenAFS with USE=fuse to enable it."
ewarn "2. Use native kernel AFS client: configure your kernel with CONFIG_AFS_FS."
ewarn "net-fs/openafs is not required in this case, but client's functionality will be limited."
fi
}
pkg_setup() {
use kernel_linux && linux-mod-r1_pkg_setup
}
src_prepare() {
default
# fixing 2-nd level makefiles to honor flags
sed -i -r 's/\<CFLAGS[[:space:]]*=/CFLAGS+=/; s/\<LDFLAGS[[:space:]]*=/LDFLAGS+=/' \
src/*/Makefile.in || die '*/Makefile.in sed failed'
# build system is very delicate, so we can't run eautoreconf
# run autotools commands based on what is listed in regen.sh
_elibtoolize -c -f -i
eaclocal -I src/cf -I src/external/rra-c-util/m4 -I src/external/autoconf-archive/m4
eautoconf
eautoconf -o configure-libafs configure-libafs.ac
eautoheader
einfo "Deleting autom4te.cache directory"
rm -rf autom4te.cache || die
}
src_configure() {
# requires the --enable-static to avoid build errors. This is
# currently an upstream limitation.
local myconf=(
--enable-static
--disable-strip-binaries
$(use_enable bitmap-later)
$(use_enable debug)
$(use_enable debug debug-locks)
$(use_enable debug debug-lwp)
$(use_enable fuse fuse-client)
$(use_enable kauth)
$(use_enable modules kernel-module)
$(use_enable namei namei-fileserver)
$(use_enable ncurses gtx)
$(use_enable pthreaded-ubik)
$(use_enable supergroups)
$(use_enable ubik-read-while-write)
$(use_with apidoc dot)
$(use_with doc docbook-stylesheets /usr/share/sgml/docbook/xsl-stylesheets)
$(use_with kerberos krb5)
$(use_with perl swig)
)
# bug #861368
filter-lto
if use debug; then
use kauth && myconf+=( --enable-debug-pam )
use modules && myconf+=( --enable-debug-kernel )
fi
if use modules; then
if use kernel_linux; then
if kernel_is -ge 3 17 && kernel_is -le 3 17 2; then
myconf+=( --enable-linux-d_splice_alias-extra-iput )
fi
myconf+=( --with-linux-kernel-headers="${KV_DIR}" \
--with-linux-kernel-build="${KV_OUT_DIR}" )
fi
fi
use amd64 && use tsm && myconf+=( --enable-tivoli-tsm )
local ARCH="$(tc-arch-kernel)"
local MY_ARCH="$(tc-arch)"
local BSD_BUILD_DIR="/usr/src/sys/${MY_ARCH}/compile/GENERIC"
AFS_SYSKVERS=26 \
econf "${myconf[@]}"
}
src_compile() {
ARCH="$(tc-arch-kernel)" AR="$(tc-getAR)" emake V=1
local d
if use doc; then
emake -C doc/xml/AdminGuide auagd000.pdf
emake -C doc/xml/AdminRef auarf000.pdf
emake -C doc/xml/QuickStartUnix auqbg000.pdf
emake -C doc/xml/UserGuide auusg000.pdf
fi
if use apidoc; then
doxygen doc/doxygen/Doxyfile || die "Failed to build doxygen files"
fi
}
src_install() {
local OPENRCDIR="${FILESDIR}/openrc"
local SYSTEMDDIR="${FILESDIR}/systemd"
emake DESTDIR="${ED}" install_nolibafs
if use modules; then
if use kernel_linux; then
local srcdir=$(expr "${S}"/src/libafs/MODLOAD-*)
[[ -f ${srcdir}/libafs.ko ]] || die "Couldn't find compiled kernel module"
linux_domodule ${srcdir}/libafs.ko
modules_post_process
fi
fi
insinto /etc/openafs
doins src/afsd/CellServDB
newins "${FILESDIR}/ThisCell.default" ThisCell
newins "${FILESDIR}/cacheinfo.default" cacheinfo
# pam_afs and pam_afs.krb have been installed in irregular locations, fix
if use kauth; then
dopammod "${ED}"/usr/$(get_libdir)/pam_afs*
fi
rm -f "${ED}"/usr/$(get_libdir)/pam_afs* || die
# remove kdump stuff provided by kexec-tools #222455
rm -rf "${ED}"/usr/sbin/kdump* || die
# avoid collision with mit_krb5's version of kpasswd
if use kauth; then
mv "${ED}"/usr/bin/kpasswd{,_afs} || die
mv "${ED}"/usr/share/man/man1/kpasswd{,_afs}.1 || die
fi
# avoid collision with heimdal's pagsh
if has_version app-crypt/heimdal; then
mv "${ED}"/usr/bin/pagsh{,_afs} || die
mv "${ED}"/usr/share/man/man1/pagsh{,_afs}.1 || die
fi
# move lwp stuff around #200674 #330061
mv "${ED}"/usr/include/{lwp,lock,timer}.h "${ED}"/usr/include/afs/ || die
mv "${ED}"/usr/$(get_libdir)/liblwp* "${ED}"/usr/$(get_libdir)/afs/ || die
# update paths to the relocated lwp headers
sed -ri \
-e '/^#include <(lwp|lock|timer).h>/s:<([^>]*)>:<afs/\1>:' \
"${ED}"/usr/include/*.h \
"${ED}"/usr/include/*/*.h \
|| die
# minimal documentation
use kauth && doman src/pam/pam_afs.5
DOCS=( "${FILESDIR}/README.Gentoo" src/afsd/CellServDB NEWS README )
# documentation package
rm -rf doc/txt/winnotes || die # unneeded docs
if use doc; then
DOCS+=( doc/{pdf,protocol,txt} CODING CONTRIBUTING )
newdoc doc/xml/AdminGuide/auagd000.pdf AdminGuide.pdf
newdoc doc/xml/AdminRef/auarf000.pdf AdminRef.pdf
newdoc doc/xml/QuickStartUnix/auqbg000.pdf QuickStartUnix.pdf
newdoc doc/xml/UserGuide/auusg000.pdf UserGuide.pdf
fi
use apidoc && DOCS+=( doc/doxygen/output/html )
einstalldocs
# Gentoo related scripts
newinitd "${OPENRCDIR}"/openafs-client.initd openafs-client
newconfd "${OPENRCDIR}"/openafs-client.confd openafs-client
newinitd "${OPENRCDIR}"/openafs-server.initd openafs-server
newconfd "${OPENRCDIR}"/openafs-server.confd openafs-server
dotmpfiles "${SYSTEMDDIR}"/tmpfiles.d/openafs-client.conf
systemd_dounit "${SYSTEMDDIR}"/openafs-client.service
systemd_dounit "${SYSTEMDDIR}"/openafs-server.service
systemd_install_serviced "${SYSTEMDDIR}"/openafs-client.service.conf
systemd_install_serviced "${SYSTEMDDIR}"/openafs-server.service.conf
# used directories: client
keepdir /etc/openafs
# used directories: server
keepdir /etc/openafs/server
diropts -m0700
keepdir /var/lib/openafs
keepdir /var/lib/openafs/db
diropts -m0755
keepdir /var/lib/openafs/logs
# link logfiles to /var/log
dosym ../lib/openafs/logs /var/log/openafs
}
pkg_preinst() {
## Somewhat intelligently install default configuration files
## (when they are not present)
local x
for x in cacheinfo CellServDB ThisCell ; do
if [[ -e "${EROOT}"/etc/openafs/${x} ]] ; then
cp "${EROOT}"/etc/openafs/${x} "${ED}"/etc/openafs/
fi
done
}
pkg_postinst() {
use kernel_linux && linux-mod-r1_pkg_postinst
tmpfiles_process openafs-client.conf
elog "This installation should work out of the box (at least the"
elog "client part doing global afs-cell browsing, unless you had"
elog "a previous and different configuration). If you want to"
elog "set up your own cell or modify the standard config,"
elog "please have a look at the Gentoo OpenAFS documentation"
elog "(warning: it is not yet up to date wrt the new file locations)"
elog
elog "The documentation can be found at:"
elog " https://wiki.gentoo.org/wiki/OpenAFS"
elog
elog "Systemd users should run emerge --config ${CATEGORY}/${PN} before"
elog "first use and whenever ${EROOT}/etc/openafs/cacheinfo is edited."
}
pkg_config() {
elog "Setting cache options for systemd."
SERVICED_FILE="${EROOT}"/etc/systemd/system/openafs-client.service.d/00gentoo.conf
[[ ! -e "${SERVICED_FILE}" ]] && die "Systemd service.d file ${SERVICED_FILE} not found."
CACHESIZE=$(cut -d ':' -f 3 "${EROOT}"/etc/openafs/cacheinfo)
[[ -z ${CACHESIZE} ]] && die "Failed to parse ${EROOT}/etc/openafs/cacheinfo."
if [[ ${CACHESIZE} -lt 131070 ]]; then
AFSD_CACHE_ARGS="-stat 300 -dcache 100 -daemons 2 -volumes 50"
elif [[ ${CACHESIZE} -lt 524288 ]]; then
AFSD_CACHE_ARGS="-stat 2000 -dcache 800 -daemons 3 -volumes 70"
elif [[ ${CACHESIZE} -lt 1048576 ]]; then
AFSD_CACHE_ARGS="-stat 2800 -dcache 2400 -daemons 5 -volumes 128"
elif [[ ${CACHESIZE} -lt 2209715 ]]; then
AFSD_CACHE_ARGS="-stat 3600 -dcache 3600 -daemons 5 -volumes 196 -files 50000"
else
AFSD_CACHE_ARGS="-stat 4000 -dcache 4000 -daemons 6 -volumes 256 -files 50000"
fi
# Replace existing env var if exists, else append line
grep -q "^Environment=\"AFSD_CACHE_ARGS=" "${SERVICED_FILE}" && \
sed -i "s/^Environment=\"AFSD_CACHE_ARGS=.*/Environment=\"AFSD_CACHE_ARGS=${AFSD_CACHE_ARGS}\"/" "${SERVICED_FILE}" || \
sed -i "$ a\Environment=\"AFSD_CACHE_ARGS=${AFSD_CACHE_ARGS}\"" "${SERVICED_FILE}" || \
die "Updating ${SERVICED_FILE} failed."
}
+348
View File
@@ -0,0 +1,348 @@
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
MODULES_OPTIONAL_IUSE="modules"
inherit autotools linux-mod-r1 flag-o-matic pam systemd tmpfiles toolchain-funcs
MY_PV=${PV/_/}
MY_P="${PN}-${MY_PV}"
KERNEL_LIMIT=6.12
DESCRIPTION="The OpenAFS distributed file system"
HOMEPAGE="https://www.openafs.org/"
# We always d/l the doc tarball as man pages are not USE=doc material
[[ ${PV} == *_pre* ]] && MY_PRE="candidate/" || MY_PRE=""
SRC_URI="
https://openafs.org/dl/openafs/${MY_PRE}${MY_PV}/${MY_P}-src.tar.bz2
https://openafs.org/dl/openafs/${MY_PRE}${MY_PV}/${MY_P}-doc.tar.bz2
"
S="${WORKDIR}/${MY_P}"
LICENSE="IBM BSD openafs-krb5-a APSL-2"
SLOT="0"
KEYWORDS="~amd64 -riscv ~sparc ~x86 ~amd64-linux ~x86-linux"
IUSE="apidoc bitmap-later debug doc fuse kauth kerberos +modules +namei
ncurses perl +pthreaded-ubik selinux +supergroups tsm ubik-read-while-write"
BDEPEND="
dev-lang/perl
app-alternatives/lex
app-alternatives/yacc
apidoc? (
app-text/doxygen[dot]
media-gfx/graphviz
)
doc? (
dev-libs/libxslt
|| (
>=dev-java/fop-2.10-r1:0
app-text/dblatex
app-text/docbook-sgml-utils[jadetex]
)
)
perl? ( dev-lang/swig )"
DEPEND="
virtual/libcrypt:=
virtual/libintl
amd64? ( tsm? ( app-backup/tsm ) )
doc? (
app-text/docbook-xsl-stylesheets
app-text/docbook-xml-dtd:4.3
)
fuse? ( sys-fs/fuse:0= )
kauth? ( sys-libs/pam )
kerberos? ( virtual/krb5 )
ncurses? ( sys-libs/ncurses:0= )"
RDEPEND="
${DEPEND}
selinux? ( sec-policy/selinux-afs )"
PATCHES=(
"${FILESDIR}"/0001-autoconf-use-AC_CHECK_TOOL-for-as-and-ld.patch
"${FILESDIR}"/0002-pam-paths.patch
"${FILESDIR}"/0003-fbsd.patch
"${FILESDIR}"/0004-sparc.patch
"${FILESDIR}"/0005-uname.patch
"${FILESDIR}"/0006-resolv.patch
"${FILESDIR}"/0007-afsauthent-symbols.patch
"${FILESDIR}"/0008-flags.patch
"${FILESDIR}"/0009-docbook2pdf.patch
"${FILESDIR}"/0010-libperl.patch
"${FILESDIR}"/0011-xbsa.patch
"${FILESDIR}"/0012-xml-dtd.patch
"${FILESDIR}"/0013-kernel-cc-ld.patch
"${FILESDIR}"/0014-upstream-struct-init.patch
"${FILESDIR}"/0015-upstream-struct-desiginated-init.patch
)
# see https://bugs.gentoo.org/943641
# Upstream performs uses customized autoconf routines to check for
# the availability of various functions and the warnings/errors in
# the config log for implicit function declarations are expected
# and therefore are false positives.
QA_CONFIG_IMPL_DECL_SKIP=("*")
CONFIG_CHECK="~!AFS_FS KEYS"
ERROR_AFS_FS="OpenAFS conflicts with the in-kernel AFS-support. Make sure not to load both at the same time!"
ERROR_KEYS="OpenAFS needs CONFIG_KEYS option enabled"
pkg_pretend() {
if use modules && use kernel_linux && kernel_is -ge ${KERNEL_LIMIT/\./ } ; then
ewarn "Gentoo supports kernels which are supported by OpenAFS"
ewarn "which are limited to the kernel versions: < ${KERNEL_LIMIT}"
ewarn ""
ewarn "You are free to utilize eapply_user to provide whatever"
ewarn "support you feel is appropriate, but will not receive"
ewarn "support as a result of those changes."
ewarn ""
ewarn "Please do not file a bug report about this."
ewarn ""
ewarn "Alternatively, you may:"
ewarn "1. Use OpenAFS FUSE client, build OpenAFS with USE=fuse to enable it."
ewarn "2. Use native kernel AFS client: configure your kernel with CONFIG_AFS_FS."
ewarn "net-fs/openafs is not required in this case, but client's functionality will be limited."
fi
}
pkg_setup() {
use kernel_linux && linux-mod-r1_pkg_setup
}
src_prepare() {
default
# fixing 2-nd level makefiles to honor flags
sed -i -r 's/\<CFLAGS[[:space:]]*=/CFLAGS+=/; s/\<LDFLAGS[[:space:]]*=/LDFLAGS+=/' \
src/*/Makefile.in || die '*/Makefile.in sed failed'
# build system is very delicate, so we can't run eautoreconf
# run autotools commands based on what is listed in regen.sh
_elibtoolize -c -f -i
eaclocal -I src/cf -I src/external/rra-c-util/m4 -I src/external/autoconf-archive/m4
eautoconf
eautoconf -o configure-libafs configure-libafs.ac
eautoheader
einfo "Deleting autom4te.cache directory"
rm -rf autom4te.cache || die
}
src_configure() {
# requires the --enable-static to avoid build errors. This is
# currently an upstream limitation.
local myconf=(
--enable-static
--disable-strip-binaries
$(use_enable bitmap-later)
$(use_enable debug)
$(use_enable debug debug-locks)
$(use_enable debug debug-lwp)
$(use_enable fuse fuse-client)
$(use_enable kauth)
$(use_enable modules kernel-module)
$(use_enable namei namei-fileserver)
$(use_enable ncurses gtx)
$(use_enable pthreaded-ubik)
$(use_enable supergroups)
$(use_enable ubik-read-while-write)
$(use_with apidoc dot)
$(use_with doc docbook-stylesheets /usr/share/sgml/docbook/xsl-stylesheets)
$(use_with kerberos krb5)
$(use_with perl swig)
)
# bug #861368
filter-lto
if use debug; then
use kauth && myconf+=( --enable-debug-pam )
use modules && myconf+=( --enable-debug-kernel )
fi
if use modules; then
if use kernel_linux; then
if kernel_is -ge 3 17 && kernel_is -le 3 17 2; then
myconf+=( --enable-linux-d_splice_alias-extra-iput )
fi
myconf+=( --with-linux-kernel-headers="${KV_DIR}" \
--with-linux-kernel-build="${KV_OUT_DIR}" )
fi
fi
use amd64 && use tsm && myconf+=( --enable-tivoli-tsm )
local ARCH="$(tc-arch-kernel)"
local MY_ARCH="$(tc-arch)"
local BSD_BUILD_DIR="/usr/src/sys/${MY_ARCH}/compile/GENERIC"
AFS_SYSKVERS=26 \
econf "${myconf[@]}"
}
src_compile() {
ARCH="$(tc-arch-kernel)" AR="$(tc-getAR)" emake V=1
local d
if use doc; then
emake -C doc/xml/AdminGuide auagd000.pdf
emake -C doc/xml/AdminRef auarf000.pdf
emake -C doc/xml/QuickStartUnix auqbg000.pdf
emake -C doc/xml/UserGuide auusg000.pdf
fi
if use apidoc; then
doxygen doc/doxygen/Doxyfile || die "Failed to build doxygen files"
fi
}
src_install() {
local OPENRCDIR="${FILESDIR}/openrc"
local SYSTEMDDIR="${FILESDIR}/systemd"
emake DESTDIR="${ED}" install_nolibafs
if use modules; then
if use kernel_linux; then
local srcdir=$(expr "${S}"/src/libafs/MODLOAD-*)
[[ -f ${srcdir}/libafs.ko ]] || die "Couldn't find compiled kernel module"
linux_domodule ${srcdir}/libafs.ko
modules_post_process
fi
fi
insinto /etc/openafs
doins src/afsd/CellServDB
newins "${FILESDIR}/ThisCell.default" ThisCell
newins "${FILESDIR}/cacheinfo.default" cacheinfo
# pam_afs and pam_afs.krb have been installed in irregular locations, fix
if use kauth; then
dopammod "${ED}"/usr/$(get_libdir)/pam_afs*
fi
rm -f "${ED}"/usr/$(get_libdir)/pam_afs* || die
# remove kdump stuff provided by kexec-tools #222455
rm -rf "${ED}"/usr/sbin/kdump* || die
# avoid collision with mit_krb5's version of kpasswd
if use kauth; then
mv "${ED}"/usr/bin/kpasswd{,_afs} || die
mv "${ED}"/usr/share/man/man1/kpasswd{,_afs}.1 || die
fi
# avoid collision with heimdal's pagsh
if has_version app-crypt/heimdal; then
mv "${ED}"/usr/bin/pagsh{,_afs} || die
mv "${ED}"/usr/share/man/man1/pagsh{,_afs}.1 || die
fi
# move lwp stuff around #200674 #330061
mv "${ED}"/usr/include/{lwp,lock,timer}.h "${ED}"/usr/include/afs/ || die
mv "${ED}"/usr/$(get_libdir)/liblwp* "${ED}"/usr/$(get_libdir)/afs/ || die
# update paths to the relocated lwp headers
sed -ri \
-e '/^#include <(lwp|lock|timer).h>/s:<([^>]*)>:<afs/\1>:' \
"${ED}"/usr/include/*.h \
"${ED}"/usr/include/*/*.h \
|| die
# minimal documentation
use kauth && doman src/pam/pam_afs.5
DOCS=( "${FILESDIR}/README.Gentoo" src/afsd/CellServDB NEWS README )
# documentation package
rm -rf doc/txt/winnotes || die # unneeded docs
if use doc; then
DOCS+=( doc/{pdf,protocol,txt} CODING CONTRIBUTING )
newdoc doc/xml/AdminGuide/auagd000.pdf AdminGuide.pdf
newdoc doc/xml/AdminRef/auarf000.pdf AdminRef.pdf
newdoc doc/xml/QuickStartUnix/auqbg000.pdf QuickStartUnix.pdf
newdoc doc/xml/UserGuide/auusg000.pdf UserGuide.pdf
fi
use apidoc && DOCS+=( doc/doxygen/output/html )
einstalldocs
# Gentoo related scripts
newinitd "${OPENRCDIR}"/openafs-client.initd openafs-client
newconfd "${OPENRCDIR}"/openafs-client.confd openafs-client
newinitd "${OPENRCDIR}"/openafs-server.initd openafs-server
newconfd "${OPENRCDIR}"/openafs-server.confd openafs-server
dotmpfiles "${SYSTEMDDIR}"/tmpfiles.d/openafs-client.conf
systemd_dounit "${SYSTEMDDIR}"/openafs-client.service
systemd_dounit "${SYSTEMDDIR}"/openafs-server.service
systemd_install_serviced "${SYSTEMDDIR}"/openafs-client.service.conf
systemd_install_serviced "${SYSTEMDDIR}"/openafs-server.service.conf
# used directories: client
keepdir /etc/openafs
# used directories: server
keepdir /etc/openafs/server
diropts -m0700
keepdir /var/lib/openafs
keepdir /var/lib/openafs/db
diropts -m0755
keepdir /var/lib/openafs/logs
# link logfiles to /var/log
dosym ../lib/openafs/logs /var/log/openafs
}
pkg_preinst() {
## Somewhat intelligently install default configuration files
## (when they are not present)
local x
for x in cacheinfo CellServDB ThisCell ; do
if [[ -e "${EROOT}"/etc/openafs/${x} ]] ; then
cp "${EROOT}"/etc/openafs/${x} "${ED}"/etc/openafs/
fi
done
}
pkg_postinst() {
use kernel_linux && linux-mod-r1_pkg_postinst
tmpfiles_process openafs-client.conf
elog "This installation should work out of the box (at least the"
elog "client part doing global afs-cell browsing, unless you had"
elog "a previous and different configuration). If you want to"
elog "set up your own cell or modify the standard config,"
elog "please have a look at the Gentoo OpenAFS documentation"
elog "(warning: it is not yet up to date wrt the new file locations)"
elog
elog "The documentation can be found at:"
elog " https://wiki.gentoo.org/wiki/OpenAFS"
elog
elog "Systemd users should run emerge --config ${CATEGORY}/${PN} before"
elog "first use and whenever ${EROOT}/etc/openafs/cacheinfo is edited."
}
pkg_config() {
elog "Setting cache options for systemd."
SERVICED_FILE="${EROOT}"/etc/systemd/system/openafs-client.service.d/00gentoo.conf
[[ ! -e "${SERVICED_FILE}" ]] && die "Systemd service.d file ${SERVICED_FILE} not found."
CACHESIZE=$(cut -d ':' -f 3 "${EROOT}"/etc/openafs/cacheinfo)
[[ -z ${CACHESIZE} ]] && die "Failed to parse ${EROOT}/etc/openafs/cacheinfo."
if [[ ${CACHESIZE} -lt 131070 ]]; then
AFSD_CACHE_ARGS="-stat 300 -dcache 100 -daemons 2 -volumes 50"
elif [[ ${CACHESIZE} -lt 524288 ]]; then
AFSD_CACHE_ARGS="-stat 2000 -dcache 800 -daemons 3 -volumes 70"
elif [[ ${CACHESIZE} -lt 1048576 ]]; then
AFSD_CACHE_ARGS="-stat 2800 -dcache 2400 -daemons 5 -volumes 128"
elif [[ ${CACHESIZE} -lt 2209715 ]]; then
AFSD_CACHE_ARGS="-stat 3600 -dcache 3600 -daemons 5 -volumes 196 -files 50000"
else
AFSD_CACHE_ARGS="-stat 4000 -dcache 4000 -daemons 6 -volumes 256 -files 50000"
fi
# Replace existing env var if exists, else append line
grep -q "^Environment=\"AFSD_CACHE_ARGS=" "${SERVICED_FILE}" && \
sed -i "s/^Environment=\"AFSD_CACHE_ARGS=.*/Environment=\"AFSD_CACHE_ARGS=${AFSD_CACHE_ARGS}\"/" "${SERVICED_FILE}" || \
sed -i "$ a\Environment=\"AFSD_CACHE_ARGS=${AFSD_CACHE_ARGS}\"" "${SERVICED_FILE}" || \
die "Updating ${SERVICED_FILE} failed."
}
+348
View File
@@ -0,0 +1,348 @@
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
MODULES_OPTIONAL_IUSE="modules"
inherit autotools linux-mod-r1 flag-o-matic pam systemd tmpfiles toolchain-funcs
MY_PV=${PV/_/}
MY_P="${PN}-${MY_PV}"
KERNEL_LIMIT=6.13
DESCRIPTION="The OpenAFS distributed file system"
HOMEPAGE="https://www.openafs.org/"
# We always d/l the doc tarball as man pages are not USE=doc material
[[ ${PV} == *_pre* ]] && MY_PRE="candidate/" || MY_PRE=""
SRC_URI="
https://openafs.org/dl/openafs/${MY_PRE}${MY_PV}/${MY_P}-src.tar.bz2
https://openafs.org/dl/openafs/${MY_PRE}${MY_PV}/${MY_P}-doc.tar.bz2
"
S="${WORKDIR}/${MY_P}"
LICENSE="IBM BSD openafs-krb5-a APSL-2"
SLOT="0"
KEYWORDS="~amd64 -riscv ~sparc ~x86 ~amd64-linux ~x86-linux"
IUSE="apidoc bitmap-later debug doc fuse kauth kerberos +modules +namei
ncurses perl +pthreaded-ubik selinux +supergroups tsm ubik-read-while-write"
BDEPEND="
dev-lang/perl
app-alternatives/lex
app-alternatives/yacc
apidoc? (
app-text/doxygen[dot]
media-gfx/graphviz
)
doc? (
dev-libs/libxslt
|| (
>=dev-java/fop-2.10-r1:0
app-text/dblatex
app-text/docbook-sgml-utils[jadetex]
)
)
perl? ( dev-lang/swig )"
DEPEND="
virtual/libcrypt:=
virtual/libintl
amd64? ( tsm? ( app-backup/tsm ) )
doc? (
app-text/docbook-xsl-stylesheets
app-text/docbook-xml-dtd:4.3
)
fuse? ( sys-fs/fuse:0= )
kauth? ( sys-libs/pam )
kerberos? ( virtual/krb5 )
ncurses? ( sys-libs/ncurses:0= )"
RDEPEND="
${DEPEND}
selinux? ( sec-policy/selinux-afs )"
PATCHES=(
"${FILESDIR}"/0001-autoconf-use-AC_CHECK_TOOL-for-as-and-ld.patch
"${FILESDIR}"/0002-pam-paths.patch
"${FILESDIR}"/0003-fbsd.patch
"${FILESDIR}"/0004-sparc.patch
"${FILESDIR}"/0005-uname.patch
"${FILESDIR}"/0006-resolv.patch
"${FILESDIR}"/0007-afsauthent-symbols.patch
"${FILESDIR}"/0008-flags.patch
"${FILESDIR}"/0009-docbook2pdf.patch
"${FILESDIR}"/0010-libperl.patch
"${FILESDIR}"/0011-xbsa.patch
"${FILESDIR}"/0012-xml-dtd.patch
"${FILESDIR}"/0013-kernel-cc-ld.patch
"${FILESDIR}"/0014-upstream-struct-init.patch
"${FILESDIR}"/0015-upstream-struct-desiginated-init.patch
)
# see https://bugs.gentoo.org/943641
# Upstream performs uses customized autoconf routines to check for
# the availability of various functions and the warnings/errors in
# the config log for implicit function declarations are expected
# and therefore are false positives.
QA_CONFIG_IMPL_DECL_SKIP=("*")
CONFIG_CHECK="~!AFS_FS KEYS"
ERROR_AFS_FS="OpenAFS conflicts with the in-kernel AFS-support. Make sure not to load both at the same time!"
ERROR_KEYS="OpenAFS needs CONFIG_KEYS option enabled"
pkg_pretend() {
if use modules && use kernel_linux && kernel_is -ge ${KERNEL_LIMIT/\./ } ; then
ewarn "Gentoo supports kernels which are supported by OpenAFS"
ewarn "which are limited to the kernel versions: < ${KERNEL_LIMIT}"
ewarn ""
ewarn "You are free to utilize eapply_user to provide whatever"
ewarn "support you feel is appropriate, but will not receive"
ewarn "support as a result of those changes."
ewarn ""
ewarn "Please do not file a bug report about this."
ewarn ""
ewarn "Alternatively, you may:"
ewarn "1. Use OpenAFS FUSE client, build OpenAFS with USE=fuse to enable it."
ewarn "2. Use native kernel AFS client: configure your kernel with CONFIG_AFS_FS."
ewarn "net-fs/openafs is not required in this case, but client's functionality will be limited."
fi
}
pkg_setup() {
use kernel_linux && linux-mod-r1_pkg_setup
}
src_prepare() {
default
# fixing 2-nd level makefiles to honor flags
sed -i -r 's/\<CFLAGS[[:space:]]*=/CFLAGS+=/; s/\<LDFLAGS[[:space:]]*=/LDFLAGS+=/' \
src/*/Makefile.in || die '*/Makefile.in sed failed'
# build system is very delicate, so we can't run eautoreconf
# run autotools commands based on what is listed in regen.sh
_elibtoolize -c -f -i
eaclocal -I src/cf -I src/external/rra-c-util/m4 -I src/external/autoconf-archive/m4
eautoconf
eautoconf -o configure-libafs configure-libafs.ac
eautoheader
einfo "Deleting autom4te.cache directory"
rm -rf autom4te.cache || die
}
src_configure() {
# requires the --enable-static to avoid build errors. This is
# currently an upstream limitation.
local myconf=(
--enable-static
--disable-strip-binaries
$(use_enable bitmap-later)
$(use_enable debug)
$(use_enable debug debug-locks)
$(use_enable debug debug-lwp)
$(use_enable fuse fuse-client)
$(use_enable kauth)
$(use_enable modules kernel-module)
$(use_enable namei namei-fileserver)
$(use_enable ncurses gtx)
$(use_enable pthreaded-ubik)
$(use_enable supergroups)
$(use_enable ubik-read-while-write)
$(use_with apidoc dot)
$(use_with doc docbook-stylesheets /usr/share/sgml/docbook/xsl-stylesheets)
$(use_with kerberos krb5)
$(use_with perl swig)
)
# bug #861368
filter-lto
if use debug; then
use kauth && myconf+=( --enable-debug-pam )
use modules && myconf+=( --enable-debug-kernel )
fi
if use modules; then
if use kernel_linux; then
if kernel_is -ge 3 17 && kernel_is -le 3 17 2; then
myconf+=( --enable-linux-d_splice_alias-extra-iput )
fi
myconf+=( --with-linux-kernel-headers="${KV_DIR}" \
--with-linux-kernel-build="${KV_OUT_DIR}" )
fi
fi
use amd64 && use tsm && myconf+=( --enable-tivoli-tsm )
local ARCH="$(tc-arch-kernel)"
local MY_ARCH="$(tc-arch)"
local BSD_BUILD_DIR="/usr/src/sys/${MY_ARCH}/compile/GENERIC"
AFS_SYSKVERS=26 \
econf "${myconf[@]}"
}
src_compile() {
ARCH="$(tc-arch-kernel)" AR="$(tc-getAR)" emake V=1
local d
if use doc; then
emake -C doc/xml/AdminGuide auagd000.pdf
emake -C doc/xml/AdminRef auarf000.pdf
emake -C doc/xml/QuickStartUnix auqbg000.pdf
emake -C doc/xml/UserGuide auusg000.pdf
fi
if use apidoc; then
doxygen doc/doxygen/Doxyfile || die "Failed to build doxygen files"
fi
}
src_install() {
local OPENRCDIR="${FILESDIR}/openrc"
local SYSTEMDDIR="${FILESDIR}/systemd"
emake DESTDIR="${ED}" install_nolibafs
if use modules; then
if use kernel_linux; then
local srcdir=$(expr "${S}"/src/libafs/MODLOAD-*)
[[ -f ${srcdir}/libafs.ko ]] || die "Couldn't find compiled kernel module"
linux_domodule ${srcdir}/libafs.ko
modules_post_process
fi
fi
insinto /etc/openafs
doins src/afsd/CellServDB
newins "${FILESDIR}/ThisCell.default" ThisCell
newins "${FILESDIR}/cacheinfo.default" cacheinfo
# pam_afs and pam_afs.krb have been installed in irregular locations, fix
if use kauth; then
dopammod "${ED}"/usr/$(get_libdir)/pam_afs*
fi
rm -f "${ED}"/usr/$(get_libdir)/pam_afs* || die
# remove kdump stuff provided by kexec-tools #222455
rm -rf "${ED}"/usr/sbin/kdump* || die
# avoid collision with mit_krb5's version of kpasswd
if use kauth; then
mv "${ED}"/usr/bin/kpasswd{,_afs} || die
mv "${ED}"/usr/share/man/man1/kpasswd{,_afs}.1 || die
fi
# avoid collision with heimdal's pagsh
if has_version app-crypt/heimdal; then
mv "${ED}"/usr/bin/pagsh{,_afs} || die
mv "${ED}"/usr/share/man/man1/pagsh{,_afs}.1 || die
fi
# move lwp stuff around #200674 #330061
mv "${ED}"/usr/include/{lwp,lock,timer}.h "${ED}"/usr/include/afs/ || die
mv "${ED}"/usr/$(get_libdir)/liblwp* "${ED}"/usr/$(get_libdir)/afs/ || die
# update paths to the relocated lwp headers
sed -ri \
-e '/^#include <(lwp|lock|timer).h>/s:<([^>]*)>:<afs/\1>:' \
"${ED}"/usr/include/*.h \
"${ED}"/usr/include/*/*.h \
|| die
# minimal documentation
use kauth && doman src/pam/pam_afs.5
DOCS=( "${FILESDIR}/README.Gentoo" src/afsd/CellServDB NEWS README )
# documentation package
rm -rf doc/txt/winnotes || die # unneeded docs
if use doc; then
DOCS+=( doc/{pdf,protocol,txt} CODING CONTRIBUTING )
newdoc doc/xml/AdminGuide/auagd000.pdf AdminGuide.pdf
newdoc doc/xml/AdminRef/auarf000.pdf AdminRef.pdf
newdoc doc/xml/QuickStartUnix/auqbg000.pdf QuickStartUnix.pdf
newdoc doc/xml/UserGuide/auusg000.pdf UserGuide.pdf
fi
use apidoc && DOCS+=( doc/doxygen/output/html )
einstalldocs
# Gentoo related scripts
newinitd "${OPENRCDIR}"/openafs-client.initd openafs-client
newconfd "${OPENRCDIR}"/openafs-client.confd openafs-client
newinitd "${OPENRCDIR}"/openafs-server.initd openafs-server
newconfd "${OPENRCDIR}"/openafs-server.confd openafs-server
dotmpfiles "${SYSTEMDDIR}"/tmpfiles.d/openafs-client.conf
systemd_dounit "${SYSTEMDDIR}"/openafs-client.service
systemd_dounit "${SYSTEMDDIR}"/openafs-server.service
systemd_install_serviced "${SYSTEMDDIR}"/openafs-client.service.conf
systemd_install_serviced "${SYSTEMDDIR}"/openafs-server.service.conf
# used directories: client
keepdir /etc/openafs
# used directories: server
keepdir /etc/openafs/server
diropts -m0700
keepdir /var/lib/openafs
keepdir /var/lib/openafs/db
diropts -m0755
keepdir /var/lib/openafs/logs
# link logfiles to /var/log
dosym ../lib/openafs/logs /var/log/openafs
}
pkg_preinst() {
## Somewhat intelligently install default configuration files
## (when they are not present)
local x
for x in cacheinfo CellServDB ThisCell ; do
if [[ -e "${EROOT}"/etc/openafs/${x} ]] ; then
cp "${EROOT}"/etc/openafs/${x} "${ED}"/etc/openafs/
fi
done
}
pkg_postinst() {
use kernel_linux && linux-mod-r1_pkg_postinst
tmpfiles_process openafs-client.conf
elog "This installation should work out of the box (at least the"
elog "client part doing global afs-cell browsing, unless you had"
elog "a previous and different configuration). If you want to"
elog "set up your own cell or modify the standard config,"
elog "please have a look at the Gentoo OpenAFS documentation"
elog "(warning: it is not yet up to date wrt the new file locations)"
elog
elog "The documentation can be found at:"
elog " https://wiki.gentoo.org/wiki/OpenAFS"
elog
elog "Systemd users should run emerge --config ${CATEGORY}/${PN} before"
elog "first use and whenever ${EROOT}/etc/openafs/cacheinfo is edited."
}
pkg_config() {
elog "Setting cache options for systemd."
SERVICED_FILE="${EROOT}"/etc/systemd/system/openafs-client.service.d/00gentoo.conf
[[ ! -e "${SERVICED_FILE}" ]] && die "Systemd service.d file ${SERVICED_FILE} not found."
CACHESIZE=$(cut -d ':' -f 3 "${EROOT}"/etc/openafs/cacheinfo)
[[ -z ${CACHESIZE} ]] && die "Failed to parse ${EROOT}/etc/openafs/cacheinfo."
if [[ ${CACHESIZE} -lt 131070 ]]; then
AFSD_CACHE_ARGS="-stat 300 -dcache 100 -daemons 2 -volumes 50"
elif [[ ${CACHESIZE} -lt 524288 ]]; then
AFSD_CACHE_ARGS="-stat 2000 -dcache 800 -daemons 3 -volumes 70"
elif [[ ${CACHESIZE} -lt 1048576 ]]; then
AFSD_CACHE_ARGS="-stat 2800 -dcache 2400 -daemons 5 -volumes 128"
elif [[ ${CACHESIZE} -lt 2209715 ]]; then
AFSD_CACHE_ARGS="-stat 3600 -dcache 3600 -daemons 5 -volumes 196 -files 50000"
else
AFSD_CACHE_ARGS="-stat 4000 -dcache 4000 -daemons 6 -volumes 256 -files 50000"
fi
# Replace existing env var if exists, else append line
grep -q "^Environment=\"AFSD_CACHE_ARGS=" "${SERVICED_FILE}" && \
sed -i "s/^Environment=\"AFSD_CACHE_ARGS=.*/Environment=\"AFSD_CACHE_ARGS=${AFSD_CACHE_ARGS}\"/" "${SERVICED_FILE}" || \
sed -i "$ a\Environment=\"AFSD_CACHE_ARGS=${AFSD_CACHE_ARGS}\"" "${SERVICED_FILE}" || \
die "Updating ${SERVICED_FILE} failed."
}