}
/**
- * Retrieve file contexts from file system.
- * @param h header
- * @retval *type tag type
- * @retval *data tag value
- * @retval *count no. of data items
- * @retval *freeData data-was-malloc'ed indicator
- * @return 0 on success
- */
-static int fscontextsTag(Header h, /*@out@*/ rpmTagType * type,
- /*@out@*/ const void ** data, /*@out@*/ int_32 * count,
- /*@out@*/ int * freeData)
- /*@globals rpmGlobalMacroContext, h_errno, fileSystem @*/
- /*@modifies h, *type, *data, *count, *freeData,
- rpmGlobalMacroContext, fileSystem @*/
- /*@requires maxSet(type) >= 0 /\ maxSet(data) >= 0
- /\ maxSet(count) >= 0 /\ maxSet(freeData) >= 0 @*/
-{
- *type = RPM_STRING_ARRAY_TYPE;
- rpmfiBuildFSContexts(h, (const char ***) data, count);
- *freeData = 1;
- return 0;
-}
-
-/**
- * Retrieve file contexts from policy RE's.
- * @param h header
- * @retval *type tag type
- * @retval *data tag value
- * @retval *count no. of data items
- * @retval *freeData data-was-malloc'ed indicator
- * @return 0 on success
- */
-static int recontextsTag(Header h, /*@out@*/ rpmTagType * type,
- /*@out@*/ const void ** data, /*@out@*/ int_32 * count,
- /*@out@*/ int * freeData)
- /*@globals rpmGlobalMacroContext, h_errno, fileSystem @*/
- /*@modifies h, *type, *data, *count, *freeData,
- rpmGlobalMacroContext, fileSystem @*/
- /*@requires maxSet(type) >= 0 /\ maxSet(data) >= 0
- /\ maxSet(count) >= 0 /\ maxSet(freeData) >= 0 @*/
-{
- *type = RPM_STRING_ARRAY_TYPE;
- rpmfiBuildREContexts(h, (const char ***) data, count);
- *freeData = 1;
- return 0;
-}
-
-/**
* Retrieve file provides.
* @param h header
* @retval *type tag type
{ HEADER_EXT_TAG, "RPMTAG_FILENAMES", { filenamesTag } },
{ HEADER_EXT_TAG, "RPMTAG_FILEPROVIDE", { fileprovideTag } },
{ HEADER_EXT_TAG, "RPMTAG_FILEREQUIRE", { filerequireTag } },
- { HEADER_EXT_TAG, "RPMTAG_FSCONTEXTS", { fscontextsTag } },
{ HEADER_EXT_TAG, "RPMTAG_FSNAMES", { fsnamesTag } },
{ HEADER_EXT_TAG, "RPMTAG_FSSIZES", { fssizesTag } },
{ HEADER_EXT_TAG, "RPMTAG_INSTALLPREFIX", { instprefixTag } },
- { HEADER_EXT_TAG, "RPMTAG_RECONTEXTS", { recontextsTag } },
{ HEADER_EXT_TAG, "RPMTAG_TRIGGERCONDS", { triggercondsTag } },
{ HEADER_EXT_TAG, "RPMTAG_TRIGGERTYPE", { triggertypeTag } },
{ HEADER_EXT_FORMAT, "armor", { armorFormat } },
if (fcp) *fcp = ac;
}
-void rpmfiBuildFContexts(Header h,
- /*@out@*/ const char *** fcontextp, /*@out@*/ int * fcp)
-{
- int scareMem = 0;
- rpmfi fi = rpmfiNew(NULL, h, RPMTAG_BASENAMES, scareMem);
- const char * fcontext;
- const char ** av;
- int ac;
- size_t nb;
- char * t;
-
- if ((ac = rpmfiFC(fi)) <= 0) {
- av = NULL;
- ac = 0;
- goto exit;
- }
-
- /* Compute size of argv array blob. */
- nb = (ac + 1) * sizeof(*av);
- fi = rpmfiInit(fi, 0);
- if (fi != NULL)
- while (rpmfiNext(fi) >= 0) {
- fcontext = rpmfiFContext(fi);
- if (fcontext && *fcontext != '\0')
- nb += strlen(fcontext);
- nb += 1;
- }
-
- /* Create and load argv array. */
- av = xmalloc(nb);
- t = ((char *) av) + ((ac + 1) * sizeof(*av));
- ac = 0;
- fi = rpmfiInit(fi, 0);
- if (fi != NULL)
- while (rpmfiNext(fi) >= 0) {
- fcontext = rpmfiFContext(fi);
- av[ac++] = t;
- if (fcontext && *fcontext != '\0')
- t = stpcpy(t, fcontext);
- *t++ = '\0';
- }
- av[ac] = NULL; /* XXX tag arrays are not NULL terminated. */
- /*@=branchstate@*/
-
-exit:
- fi = rpmfiFree(fi);
- /*@-branchstate@*/
- if (fcontextp)
- *fcontextp = av;
- else
- av = _free(av);
- /*@=branchstate@*/
- if (fcp) *fcp = ac;
-}
-
-void rpmfiBuildFSContexts(Header h,
- /*@out@*/ const char *** fcontextp, /*@out@*/ int * fcp)
-{
- int scareMem = 0;
- rpmfi fi = rpmfiNew(NULL, h, RPMTAG_BASENAMES, scareMem);
- const char ** av;
- int ac;
- size_t nb;
- char * t;
- char * fctxt = NULL;
- size_t fctxtlen = 0;
- int * fcnb;
-
- if ((ac = rpmfiFC(fi)) <= 0) {
- av = NULL;
- ac = 0;
- goto exit;
- }
-
- /* Compute size of argv array blob, concatenating file contexts. */
- nb = ac * sizeof(*fcnb);
- fcnb = memset(alloca(nb), 0, nb);
- ac = 0;
- fi = rpmfiInit(fi, 0);
- if (fi != NULL)
- while (rpmfiNext(fi) >= 0) {
- const char * fn = rpmfiFN(fi);
- security_context_t scon;
-
- fcnb[ac] = lgetfilecon(fn, &scon);
-/*@-branchstate@*/
- if (fcnb[ac] > 0) {
- fctxt = xrealloc(fctxt, fctxtlen + fcnb[ac]);
- memcpy(fctxt+fctxtlen, scon, fcnb[ac]);
- fctxtlen += fcnb[ac];
- freecon(scon);
- }
-/*@=branchstate@*/
- ac++;
- }
-
- /* Create and load argv array from concatenated file contexts. */
- nb = (ac + 1) * sizeof(*av) + fctxtlen;
- av = xmalloc(nb);
- t = ((char *) av) + ((ac + 1) * sizeof(*av));
- if (fctxt != NULL && fctxtlen > 0)
- (void) memcpy(t, fctxt, fctxtlen);
- ac = 0;
- fi = rpmfiInit(fi, 0);
- if (fi != NULL)
- while (rpmfiNext(fi) >= 0) {
- av[ac] = "";
- if (fcnb[ac] > 0) {
- av[ac] = t;
- t += fcnb[ac];
- }
- ac++;
- }
- av[ac] = NULL; /* XXX tag arrays are not NULL terminated. */
-
-exit:
- fi = rpmfiFree(fi);
- /*@-branchstate@*/
- if (fcontextp)
- *fcontextp = av;
- else
- av = _free(av);
- /*@=branchstate@*/
- if (fcp) *fcp = ac;
-}
-
-void rpmfiBuildREContexts(Header h,
- /*@out@*/ const char *** fcontextp, /*@out@*/ int * fcp)
-{
- int scareMem = 0;
- rpmfi fi = rpmfiNew(NULL, h, RPMTAG_BASENAMES, scareMem);
- rpmsx sx = NULL;
- const char ** av = NULL;
- int ac;
- size_t nb;
- char * t;
- char * fctxt = NULL;
- size_t fctxtlen = 0;
- int * fcnb;
-
- if ((ac = rpmfiFC(fi)) <= 0) {
- ac = 0;
- goto exit;
- }
-
- /* Read security context patterns. */
- sx = rpmsxNew(NULL);
-
- /* Compute size of argv array blob, concatenating file contexts. */
- nb = ac * sizeof(*fcnb);
- fcnb = memset(alloca(nb), 0, nb);
- ac = 0;
- fi = rpmfiInit(fi, 0);
- if (fi != NULL)
- while (rpmfiNext(fi) >= 0) {
- const char * fn = rpmfiFN(fi);
- mode_t fmode = rpmfiFMode(fi);
- const char * scon;
-
- scon = rpmsxFContext(sx, fn, fmode);
- if (scon != NULL) {
- fcnb[ac] = strlen(scon) + 1;
-/*@-branchstate@*/
- if (fcnb[ac] > 0) {
- fctxt = xrealloc(fctxt, fctxtlen + fcnb[ac]);
- memcpy(fctxt+fctxtlen, scon, fcnb[ac]);
- fctxtlen += fcnb[ac];
- }
-/*@=branchstate@*/
- }
- ac++;
- }
-
- /* Create and load argv array from concatenated file contexts. */
- nb = (ac + 1) * sizeof(*av) + fctxtlen;
- av = xmalloc(nb);
- t = ((char *) av) + ((ac + 1) * sizeof(*av));
- (void) memcpy(t, fctxt, fctxtlen);
- ac = 0;
- fi = rpmfiInit(fi, 0);
- if (fi != NULL)
- while (rpmfiNext(fi) >= 0) {
- av[ac] = "";
- if (fcnb[ac] > 0) {
- av[ac] = t;
- t += fcnb[ac];
- }
- ac++;
- }
- av[ac] = NULL; /* XXX tag arrays are not NULL terminated. */
-
-exit:
- fi = rpmfiFree(fi);
- sx = rpmsxFree(sx);
- /*@-branchstate@*/
- if (fcontextp)
- *fcontextp = av;
- else
- av = _free(av);
- /*@=branchstate@*/
- if (fcp) *fcp = ac;
-}
-
void rpmfiBuildFDeps(Header h, rpmTag tagN,
/*@out@*/ const char *** fdepsp, /*@out@*/ int * fcp)
{
/*@globals rpmGlobalMacroContext, h_errno, fileSystem @*/
/*@modifies h, *fclassp, *fcp, rpmGlobalMacroContext, fileSystem @*/;
-/**
- * Retrieve file security contexts from header.
- *
- * This function is used to retrieve file contexts from the header.
- *
- * @param h header
- * @retval *fcontextp array of file contexts
- * @retval *fcp number of files
- */
-void rpmfiBuildFContexts(Header h,
- /*@out@*/ const char *** fcontextp, /*@out@*/ int * fcp)
- /*@globals rpmGlobalMacroContext, h_errno, fileSystem @*/
- /*@modifies h, *fcontextp, *fcp, rpmGlobalMacroContext, fileSystem @*/;
-
-/**
- * Retrieve file security contexts from file system.
- *
- * This function is used to retrieve file contexts from the file system.
- *
- * @param h header
- * @retval *fcontextp array of file contexts
- * @retval *fcp number of files
- */
-void rpmfiBuildFSContexts(Header h,
- /*@out@*/ const char *** fcontextp, /*@out@*/ int * fcp)
- /*@globals rpmGlobalMacroContext, h_errno, fileSystem @*/
- /*@modifies h, *fcontextp, *fcp, rpmGlobalMacroContext, fileSystem @*/;
-
-/**
- * Retrieve file security contexts from policy RE's.
- *
- * This function is used to retrieve file contexts from policy RE's.
- *
- * @param h header
- * @retval *fcontextp array of file contexts
- * @retval *fcp number of files
- */
-void rpmfiBuildREContexts(Header h,
- /*@out@*/ const char *** fcontextp, /*@out@*/ int * fcp)
- /*@globals rpmGlobalMacroContext, h_errno, fileSystem @*/
- /*@modifies h, *fcontextp, *fcp, rpmGlobalMacroContext, fileSystem @*/;
/**
* Retrieve per-file dependencies from header.
rpm alias --filecolor --qf '[%{FILENAMES}\t%{FILECOLORS}\n]' \
--POPTdesc=$"list file names with colors"
-rpm alias --fscontext --qf '[%{FILENAMES}\t%{FSCONTEXTS}\n]' \
- --POPTdesc=$"list file names with security context from file system"
-
-rpm alias --recontext --qf '[%{FILENAMES}\t%{RECONTEXTS}\n]' \
- --POPTdesc=$"list file names with security context from policy RE"
+rpm alias --fscontext --qf '[%{FILENAMES}\n]' \
+ --pipe "xargs ls --scontext | awk '{printf(\"%s %s\n\", $2, $1)}'" \
+ --POPTdesc=$"list file names with security context from file system"
rpm alias --fileprovide --qf '[%{FILENAMES}\t%{FILEPROVIDE}\n]' \
--POPTdesc=$"list file names with provides"
rpmquery alias --filecolor --qf '[%{FILENAMES}\t%{FILECOLORS}\n]' \
--POPTdesc=$"list file names with colors"
-rpmquery alias --filecontext --qf '[%{FILENAMES}\t%{FILECONTEXTS}\n]' \
- --POPTdesc=$"list file names with security context"
-
-rpmquery alias --fscontext --qf '[%{FILENAMES}\t%{FSCONTEXTS}\n]' \
- --POPTdesc=$"list file names with security context from file system"
-
-rpmquery alias --recontext --qf '[%{FILENAMES}\t%{RECONTEXTS}\n]' \
- --POPTdesc=$"list file names with security context from policy RE"
+rpmquery alias --fscontext --qf '[%{FILENAMES}\n]' \
+ --pipe "xargs ls --scontext | awk '{printf(\"%s %s\n\", $2, $1)}'" \
+ --POPTdesc=$"list file names with security context from file system"
rpmquery alias --fileprovide --qf '[%{FILENAMES}\t%{FILEPROVIDE}\n]' \
--POPTdesc=$"list file names with provides"