summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.splintrc2
-rw-r--r--build/files.c19
-rw-r--r--lib/.splintrc2
-rw-r--r--lib/Makefile.am1
-rw-r--r--lib/rpmfi.c70
-rw-r--r--lib/rpmsx.h2
-rw-r--r--macros.in30
7 files changed, 63 insertions, 63 deletions
diff --git a/.splintrc b/.splintrc
index 1ffe94862..ce52bc022 100644
--- a/.splintrc
+++ b/.splintrc
@@ -1,4 +1,4 @@
--I. -I./build -I./lib -I./rpmdb -I./rpmio -I./beecrypt -I./file -I./popt -I./elfutils/libelf -I./zlib -I/usr/include/selinux -I/usr/lib/gcc-lib/i386-redhat-linux/3.1/include -DHAVE_CONFIG_H -D_GNU_SOURCE -D_REENTRANT -DHAVE_DEV_DSP -DHAVE_SYS_SOUNDCARD
+-I. -I./build -I./lib -I./rpmdb -I./rpmio -I./beecrypt -I./file -I./popt -I./elfutils/libelf -I./zlib -I/usr/lib/gcc-lib/i386-redhat-linux/3.1/include -DHAVE_CONFIG_H -D_GNU_SOURCE -D_REENTRANT -DHAVE_DEV_DSP -DHAVE_SYS_SOUNDCARD
#+partial
+forcehints
diff --git a/build/files.c b/build/files.c
index 256362f49..b8d4e864a 100644
--- a/build/files.c
+++ b/build/files.c
@@ -23,6 +23,8 @@
#define _RPMFI_INTERNAL
#include "rpmfi.h"
+#include "rpmsx.h"
+
#define _RPMTE_INTERNAL
#include "rpmte.h"
@@ -1108,6 +1110,8 @@ static void genCpioListAndHeader(/*@partial@*/ FileList fl,
int apathlen = 0;
int dpathlen = 0;
int skipLen = 0;
+ rpmsx sx = NULL;
+ const char * sxfn;
size_t fnlen;
FileListRec flp;
char buf[BUFSIZ];
@@ -1124,6 +1128,10 @@ static void genCpioListAndHeader(/*@partial@*/ FileList fl,
skipLen += strlen(fl->prefix);
}
+ sxfn = rpmGetPath("%{?_build_file_context_path}", NULL);
+ if (sxfn != NULL && *sxfn != '\0')
+ sx = rpmsxNew(sxfn);
+
for (i = 0, flp = fl->fileList; i < fl->fileListRecsUsed; i++, flp++) {
char *s;
@@ -1303,7 +1311,18 @@ static void genCpioListAndHeader(/*@partial@*/ FileList fl,
(void) headerAddOrAppendEntry(h, RPMTAG_FILEFLAGS, RPM_INT32_TYPE,
&(flp->flags), 1);
+ /* Add file security context to package. */
+ if (sx != NULL) {
+ mode_t fmode = (uint_16)flp->fl_mode;
+ s = rpmsxFContext(sx, flp->fileURL, fmode);
+ if (s == NULL) s = "";
+ (void) headerAddOrAppendEntry(h, RPMTAG_FILECONTEXTS, RPM_STRING_ARRAY_TYPE,
+ &s, 1);
+ }
+
}
+ sx = rpmsxFree(sx);
+ sxfn = _free(sxfn);
(void) headerAddEntry(h, RPMTAG_SIZE, RPM_INT32_TYPE,
&(fl->totalFileSize), 1);
diff --git a/lib/.splintrc b/lib/.splintrc
index a95520a16..0ab9a4acf 100644
--- a/lib/.splintrc
+++ b/lib/.splintrc
@@ -1,4 +1,4 @@
--I. -I.. -I../build -I../rpmdb -I../rpmio -I../beecrypt -I../popt -I../elfutils/libelf -I/usr/include/selinux -DHAVE_CONFIG_H -D_GNU_SOURCE
+-I. -I.. -I../build -I../rpmdb -I../rpmio -I../beecrypt -I../popt -I../elfutils/libelf -DHAVE_CONFIG_H -D_GNU_SOURCE
+partial
+forcehints
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 34a552bb6..fb37b44a3 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -11,7 +11,6 @@ INCLUDES = -I. \
-I$(top_srcdir)/rpmio \
@WITH_BEECRYPT_INCLUDE@ \
-I$(top_srcdir)/popt \
- -I/usr/include/selinux \
@INCPATH@
EXTRA_DIST = getdate.y
diff --git a/lib/rpmfi.c b/lib/rpmfi.c
index 98cfd810e..87745f131 100644
--- a/lib/rpmfi.c
+++ b/lib/rpmfi.c
@@ -1200,10 +1200,6 @@ rpmfi rpmfiNew(rpmts ts, Header h, rpmTag tagN, int scareMem)
uint_32 * uip;
int dnlmax, bnlmax;
unsigned char * t;
-security_context_t scon;
-int * fcnb;
-char * fctxt;
-int fctxtlen;
int len;
int xx;
int i;
@@ -1308,10 +1304,11 @@ if (fi->actions == NULL)
fi->fmd5s = hfd(fi->fmd5s, -1);
}
- /* XXX TR_REMOVED doesn;t need fmtimes, frdevs or finodes */
+ /* XXX TR_REMOVED doesn;t need fmtimes, frdevs, finodes, or fcontexts */
xx = hge(h, RPMTAG_FILEMTIMES, NULL, (void **) &fi->fmtimes, NULL);
xx = hge(h, RPMTAG_FILERDEVS, NULL, (void **) &fi->frdevs, NULL);
xx = hge(h, RPMTAG_FILEINODES, NULL, (void **) &fi->finodes, NULL);
+ xx = hge(h, RPMTAG_FILECONTEXTS, NULL, (void **) &fi->fcontexts, NULL);
fi->replacedSizes = xcalloc(fi->fc, sizeof(*fi->replacedSizes));
@@ -1428,45 +1425,6 @@ if (fi->actions == NULL)
fi->dperms = 0755;
fi->fperms = 0644;
- /* Retrieve file contexts into single contiguous buffer, saving sizes. */
- fctxt = NULL;
- fctxtlen = 0;
- len = fi->fc * sizeof(*fcnb);
- fcnb = memset(alloca(len), 0, len);
- fi->fn = xmalloc(fi->fnlen);
-/*@-branchstate@*/
- for (i = 0; i < fi->fc; i++) {
-/*@-boundswrite@*/
- *fi->fn = '\0';
- (void) stpcpy( stpcpy(fi->fn, fi->dnl[fi->dil[i]]), fi->bnl[i]);
-/*@=boundswrite@*/
- fcnb[i] = lgetfilecon(fi->fn, &scon);
- if (fcnb[i] <= 0)
- continue;
-
- fctxt = xrealloc(fctxt, fctxtlen + fcnb[i]);
- memcpy(fctxt+fctxtlen, scon, fcnb[i]);
- fctxtlen += fcnb[i];
- (void) freecon(scon);
- }
-/*@=branchstate@*/
- fi->fn = _free(fi->fn);
-
- /* Initialize array ptrs into data following array. */
- len = ((fi->fc+1) * sizeof(*fi->fcontexts)) + fctxtlen;
- fi->fcontexts = xmalloc(len);
- (void) memset(fi->fcontexts, 0, (fi->fc+1) * sizeof(*fi->fcontexts));
- (void) memcpy(&fi->fcontexts[fi->fc+1], fctxt, fctxtlen);
- fctxt = _free(fctxt);
- fctxt = (char *) (&fi->fcontexts[fi->fc+1]);
- for (i = 0; i < fi->fc; i++) {
- if (fcnb[i] <= 0)
- continue;
- fi->fcontexts[i] = fctxt;
- fctxt += fcnb[i];
- }
- fi->fcontexts[fi->fc] = NULL;
-
exit:
/*@-modfilesys@*/
if (_rpmfi_debug < 0)
@@ -1519,7 +1477,7 @@ void rpmfiBuildFClasses(Header h,
t = stpcpy(t, FClass);
*t++ = '\0';
}
- av[ac] = NULL;
+ av[ac] = NULL; /* XXX tag arrays are not NULL terminated. */
/*@=branchstate@*/
exit:
@@ -1538,7 +1496,7 @@ void rpmfiBuildFContexts(Header h,
{
int scareMem = 1;
rpmfi fi = rpmfiNew(NULL, h, RPMTAG_BASENAMES, scareMem);
- const char * FContext;
+ const char * fcontext;
const char ** av;
int ac;
size_t nb;
@@ -1555,9 +1513,9 @@ void rpmfiBuildFContexts(Header h,
fi = rpmfiInit(fi, 0);
if (fi != NULL)
while (rpmfiNext(fi) >= 0) {
- FContext = rpmfiFContext(fi);
- if (FContext && *FContext != '\0')
- nb += strlen(FContext);
+ fcontext = rpmfiFContext(fi);
+ if (fcontext && *fcontext != '\0')
+ nb += strlen(fcontext);
nb += 1;
}
@@ -1568,13 +1526,13 @@ void rpmfiBuildFContexts(Header h,
fi = rpmfiInit(fi, 0);
if (fi != NULL)
while (rpmfiNext(fi) >= 0) {
- FContext = rpmfiFContext(fi);
+ fcontext = rpmfiFContext(fi);
av[ac++] = t;
- if (FContext && *FContext != '\0')
- t = stpcpy(t, FContext);
+ if (fcontext && *fcontext != '\0')
+ t = stpcpy(t, fcontext);
*t++ = '\0';
}
- av[ac] = NULL;
+ av[ac] = NULL; /* XXX tag arrays are not NULL terminated. */
/*@=branchstate@*/
exit:
@@ -1645,7 +1603,7 @@ void rpmfiBuildFSContexts(Header h,
}
ac++;
}
- av[ac] = NULL;
+ av[ac] = NULL; /* XXX tag arrays are not NULL terminated. */
exit:
fi = rpmfiFree(fi);
@@ -1722,7 +1680,7 @@ void rpmfiBuildREContexts(Header h,
}
ac++;
}
- av[ac] = NULL;
+ av[ac] = NULL; /* XXX tag arrays are not NULL terminated. */
exit:
fi = rpmfiFree(fi);
@@ -1821,7 +1779,7 @@ void rpmfiBuildFDeps(Header h, rpmTag tagN,
*t++ = '\0';
}
/*@=branchstate@*/
- av[ac] = NULL;
+ av[ac] = NULL; /* XXX tag arrays are not NULL terminated. */
exit:
fi = rpmfiFree(fi);
diff --git a/lib/rpmsx.h b/lib/rpmsx.h
index f0076c211..bd54739c4 100644
--- a/lib/rpmsx.h
+++ b/lib/rpmsx.h
@@ -8,7 +8,7 @@
#include <regex.h>
-#include "selinux.h"
+#include <selinux/selinux.h>
#if defined(__LCLINT__)
/*@-incondefs@*/
diff --git a/macros.in b/macros.in
index 1e8f3b734..62e9d0463 100644
--- a/macros.in
+++ b/macros.in
@@ -1,7 +1,7 @@
#/*! \page config_macros Default configuration: @RPMCONFIGDIR@/macros
# \verbatim
#
-# $Id: macros.in,v 1.140 2003/12/11 19:09:59 jbj Exp $
+# $Id: macros.in,v 1.141 2003/12/23 07:51:10 jbj Exp $
#
# This is a global RPM configuration file. All changes made here will
# be lost when the rpm package is upgraded. Any per-system configuration
@@ -327,6 +327,30 @@ package or when debugging this package.\
# Filter GLIBC_PRIVATE Provides:/Requires:
%_filter_GLIBC_PRIVATE 0
+# Path to selinux src policy file context patterns.
+%__file_context_path /etc/security/selinux/src/policy/file_contexts/file_contexts
+
+#
+# Path to selinux src policy file context patterns used to add
+# RPMTAG_FILECONTEXTS to packages when building.
+#
+# Undefined, missing or %{nil} will disable.
+#%_build_file_context_path %{__file_context_path}
+
+#
+# Path to selinux src policy file context patterns used to set
+# (or override package content) file contexts when installing.
+#
+# Undefined, missing or %{nil} will use package content (if available).
+%_install_file_context_path %{__file_context_path}
+
+#
+# Path to selinux src policy file context patterns used to verify
+# file contexts on file system.
+#
+# Undefined, missing or %{nil} will use package content.
+%_verify_file_context_path %{__file_context_path}
+
#
# Path to scripts to autogenerate package dependencies,
#
@@ -509,6 +533,8 @@ package or when debugging this package.\
%_dbi_config_Installtid %{_dbi_btconfig}
%_dbi_config_Removetid %{_dbi_btconfig}
+%_dbi_config %{_dbi_htconfig}
+
# XXX legacy configuration.
# Choose db interface:
# 3 native db3 interface.
@@ -518,8 +544,6 @@ package or when debugging this package.\
%_dbapi 3
%_dbapi_rebuild 3
-%_dbi_config %{_dbi_htconfig}
-
#==============================================================================
# ---- GPG/PGP/PGP5 signature macros.
# Macro(s) to hold the arguments passed to GPG/PGP for package