RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  j...@rpm5.org
  Module: rpm                              Date:   03-May-2017 17:01:17
  Branch: rpm-5_4                          Handle: 2017050315011601

  Modified files:           (Branch: rpm-5_4)
    rpm                     CHANGES
    rpm/rpmio               rpmku.c

  Log:
    - rpmku: stub in syscall wrappers.

  Summary:
    Revision    Changes     Path
    1.3501.2.540+1  -0      rpm/CHANGES
    2.6.2.5     +158 -3     rpm/rpmio/rpmku.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.3501.2.539 -r1.3501.2.540 CHANGES
  --- rpm/CHANGES       3 May 2017 14:57:41 -0000       1.3501.2.539
  +++ rpm/CHANGES       3 May 2017 15:01:16 -0000       1.3501.2.540
  @@ -1,4 +1,5 @@
   5.4.17 -> 5.4.18:
  +    - jbj: rpmku: stub in syscall wrappers.
       - jbj: repackage: fix: memory leak recreating lead.
       - jbj: rpmio: support for O_DIRECT through Fopen.
       - jbj: autofu: refactor to add 
--with-{epoll,eventfd,fanotify,inotify,ipc,mount,personality,prctl,timerfd}.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmku.c
  ============================================================================
  $ cvs diff -u -r2.6.2.4 -r2.6.2.5 rpmku.c
  --- rpm/rpmio/rpmku.c 2 May 2017 20:18:55 -0000       2.6.2.4
  +++ rpm/rpmio/rpmku.c 3 May 2017 15:01:17 -0000       2.6.2.5
  @@ -4,9 +4,13 @@
   
   #include "system.h"
   
  +#if defined(HAVE_SYS_SYSCALL_H)
  +#include <sys/syscall.h>
  +#endif
  +
   #define      _RPMIOB_INTERNAL
  -#include <rpmiotypes.h>
  -#include <rpmio.h>
  +#include <rpmio_internal.h>
  +
   #if defined(HAVE_KEYUTILS_H)
   #include <rpmmacro.h>
   #include <argv.h>
  @@ -21,7 +25,8 @@
   
   #define _RPMPGP_INTERNAL
   #include <rpmpgp.h>
  -#endif
  +#endif       /* HAVE_KEYUTILS_H */
  +
   #include <rpmku.h>
   
   #include "debug.h"
  @@ -214,3 +219,153 @@
        pw = xstrdup(passPhrase);
       return pw;
   }
  +
  +#if defined(HAVE_KEYUTILS_H)
  +#include <keyutils.h>
  +
  +#else        /* HAVE_KEYUTILS_H */
  +
  +typedef      int32_t key_serial_t;
  +
  +#if defined(HAVE_ADD_KEY)
  +extern       key_serial_t add_key(const char *type, const char *description,
  +                            const void *payload, size_t plen,
  +                            key_serial_t ringid);
  +#else        /* defined(HAVE_ADD_KEY) */
  +static inline key_serial_t add_key(const char *type, const char *description,
  +                            const void *payload, size_t plen,
  +                            key_serial_t ringid)
  +{
  +    key_serial_t rc = -2;
  +#if defined(__linux__) && defined(SYS_add_key)
  +    rc = syscall(SYS_add_key, type, description, payload, plen, ringid);
  +#else
  +    errno = ENOSYS;
  +#endif
  +    return rc;
  +}
  +#endif       /* defined(HAVE_ADD_KEY) */
  +
  +#if defined(HAVE_REQUEST_KEY)
  +extern key_serial_t request_key(const char *type,
  +                                const char *description,
  +                                const char *callout_info,
  +                                key_serial_t destringid);
  +#else        /* defined(HAVE_REQUEST_KEY) */
  +static inline key_serial_t request_key(const char *type,
  +                                const char *description,
  +                                const char *callout_info,
  +                                key_serial_t destringid)
  +{
  +    key_serial_t rc = -2;
  +#if defined(__linux__) && defined(SYS_request_key)
  +    rc = syscall(SYS_request_key, type, description, callout_info, 
destringid);
  +#else
  +    errno = ENOSYS;
  +#endif
  +    return rc;
  +}
  +#endif       /* defined(HAVE_REQUEST_KEY) */
  +
  +#if defined(HAVE_KEYCTL)
  +extern long keyctl(int cmd, ...);
  +#else        /* defined(HAVE_KEYCTL) */
  +static inline long __keyctl(int cmd,
  +             unsigned long arg2,
  +             unsigned long arg3,
  +             unsigned long arg4,
  +             unsigned long arg5)
  +{
  +    long rc = -2;
  +#if defined(__linux__) && defined(SYS_keyctl)
  +    rc = syscall(SYS_keyctl, cmd, arg2, arg3, arg4, arg5);
  +#else
  +    errno = ENOSYS;
  +#endif
  +    return rc;
  +}
  +
  +static inline long keyctl(int cmd, ...)
  +{
  +    va_list ap;
  +    va_start(ap, cmd);
  +    unsigned long arg2 = va_arg(ap, unsigned long);
  +    unsigned long arg3 = va_arg(ap, unsigned long);
  +    unsigned long arg4 = va_arg(ap, unsigned long);
  +    unsigned long arg5 = va_arg(ap, unsigned long);
  +    va_end(ap);
  +    return __keyctl(cmd, arg2, arg3, arg4, arg5);
  +}
  +
  +#endif       /* defined(HAVE_KEYCTL) */
  +
  +#endif       /* defined(HAVE_KEYUTILS_H) */
  +
  +key_serial_t Add_key(const char *type, const char *description,
  +                            const void *payload, size_t plen,
  +                            key_serial_t ringid);
  +key_serial_t Add_key(const char *type, const char *description,
  +                            const void *payload, size_t plen,
  +                            key_serial_t ringid)
  +{
  +    key_serial_t rc = add_key(type, description, payload, plen, ringid);
  +    if (rc < 0)
  +     rpmlog(RPMLOG_ERR, _("%s(%s,%s,%p[%u],%d) failed: %m\n"),
  +             __FUNCTION__, type, description, payload, (unsigned)plen, 
(int)ringid);
  +if (_rpmio_debug)
  +fprintf(stderr, _("<-- %s(%s,%s,%p[%u],%d) rc %d\n"), __FUNCTION__, type, 
description, payload, (unsigned)plen, (int)ringid, (int)rc);
  +    return rc;
  +}
  +
  +key_serial_t Request_key(const char *type,
  +                                const char *description,
  +                                const char *callout_info,
  +                                key_serial_t destringid);
  +key_serial_t Request_key(const char *type,
  +                                const char *description,
  +                                const char *callout_info,
  +                                key_serial_t destringid)
  +{
  +    key_serial_t rc = request_key(type, description, callout_info, 
destringid);
  +    if (rc < 0)
  +     rpmlog(RPMLOG_ERR, _("%s(%s,%s,%s,%d) failed: %m\n"),
  +             __FUNCTION__, type, description, callout_info, (int)destringid);
  +if (_rpmio_debug)
  +fprintf(stderr, _("<-- %s(%s,%s,%s,%d) rc %d\n"), __FUNCTION__, type, 
description, callout_info, (int)destringid, (int)rc);
  +    return rc;
  +}
  +
  +static inline long vkeyctl(int cmd, va_list ap)
  +{
  +    long rc = -2;
  +    va_list apc;
  +    va_copy(apc, ap);
  +    unsigned long arg2 = va_arg(apc, unsigned long);
  +    unsigned long arg3 = va_arg(apc, unsigned long);
  +    unsigned long arg4 = va_arg(apc, unsigned long);
  +    unsigned long arg5 = va_arg(apc, unsigned long);
  +    va_end(apc);
  +
  +#if defined(HAVE_KEYCTL)
  +    rc = keyctl(cmd, arg2, arg3, arg4, arg5);
  +#else
  +    rc = __keyctl(cmd, arg2, arg3, arg4, arg5);
  +#endif
  +    return rc;
  +}
  +
  +long Keyctl(int cmd, ...);
  +long Keyctl(int cmd, ...)
  +{
  +    va_list ap;
  +    va_start(ap, cmd);
  +    long rc = vkeyctl(cmd, ap);
  +    va_end(ap);
  +
  +    if (rc < 0)
  +     rpmlog(RPMLOG_ERR, _("%s(%d) failed: %m\n"),
  +             __FUNCTION__, cmd);
  +if (_rpmio_debug)
  +fprintf(stderr, _("<-- %s(%d,...) rc %ld\n"), __FUNCTION__, cmd, (long)rc);
  +    return rc;
  +}
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to