Security plugin: small fixes
authorElena Reshetova <elena.reshetova@intel.com>
Mon, 19 Aug 2013 05:42:27 +0000 (08:42 +0300)
committerElena Reshetova <elena.reshetova@intel.com>
Mon, 19 Aug 2013 06:25:16 +0000 (09:25 +0300)
 - Removing unused code
 - Changing the init hook to take care of new libsmack return code

plugins/msm-plugin.c
plugins/msm.h

index b73993f2092b7484af16c760e1b1770d4bb7c6c3..bc95cf447354de25392f1aaf0c8ccea9c519cb89 100644 (file)
@@ -196,7 +196,7 @@ rpmRC PLUGINHOOK_INIT_FUNC(rpmts _ts, const char *name, const char *opts)
     if (stat(fullPath, &buf) == 0) {
         int res = smack_new_label_from_self(&ownSmackLabel);
         SmackEnabled = 1;
-        if (res != 0) {
+        if (res < 0) {
             rpmlog(RPMLOG_ERR, "Failed to obtain rpm security context\n");
             goto plugin_error;
         }
@@ -901,45 +901,6 @@ rpmRC PLUGINHOOK_CLEANUP_FUNC(void)
     return RPMRC_OK;
 }
 
-const char *msmQueryPackageFile(const char *rfor, 
-                                const char **dname, const char **pname)
-{
-    int match = 0;
-    const char *path = NULL;
-
-    if (ts) {
-        char *sep = strchr(rfor, ':');
-        if (sep && sep[1] == ':' && sep[2] == '/') 
-            path = &sep[2];
-        if (!path) return NULL;
-
-        rpmdbMatchIterator mi = rpmtsInitIterator(ts, RPMTAG_BASENAMES, path, 0);
-        if (!mi)
-            mi = rpmtsInitIterator(ts, RPMTAG_PROVIDENAME, path, 0);
-        if (mi) {
-            Header h;
-            const char *name, *sw_source;
-            while ((h = rpmdbNextIterator(mi))) {
-                rpmdbCheckSignals();
-                name = headerGetString(h, RPMTAG_NAME);
-                sw_source = headerGetString(h, RPMTAG_SECSWSOURCE);
-                if (name && sw_source) {
-                    match = !strncmp(rfor, name, path - rfor - 2);
-                    rpmlog(RPMLOG_DEBUG, "file %s belongs to package %s in sw source %s %s\n", 
-                           path, name, sw_source, (match ? "(matched request)" : ""));
-                    if (match) {
-                        *pname = xstrdup(name);
-                        *dname = xstrdup(sw_source);
-                        break;
-                    }
-                }
-            }
-            mi = rpmdbFreeIterator(mi);
-        }
-    }
-    return match ? path : NULL;
-}
-
 void msmFreePointer(void** ptr)
 {
     if (*ptr)
index bbe09275d53d0411e2aea3302f512cbfa3e2283d..1a4853a2a15e383008f076371df1c56d64d827c6 100644 (file)
@@ -457,16 +457,4 @@ sw_source_x *msmSWSourceTreeTraversal(sw_source_x *sw_sources, int (func)(sw_sou
  * Free internal hashes.
  */
 void msmFreeInternalHashes(void);
-
-/** \ingroup msm
- * Query that requested package really owns the file.
- * @param rfor         request for 'package::/file/path'
- * @param sw_sname     sw source name, caller must free
- * @param pname                package name, caller must free
- * @return             pointer to the path part in rfor, or NULL if file
- *                     is not owned by the specified package
- */
-const char *msmQueryPackageFile(const char *rfor, 
-                                const char **sw_sname, const char **pname);
-
 #endif