1. 17 10月, 2013 1 次提交
    • B
      better error checking for LOCAL_PEERCRED · aa0f0992
      Brian Candler 提交于
      This patch improves the error checking in the LOCAL_PEERCRED version
      of virNetSocketGetUNIXIdentity, used by FreeBSD and Mac OSX.
      
      1. The error return paths now correctly unlock the socket. This is
      implemented in exactly the same way as the SO_PEERCRED version,
      using "goto cleanup"
      
      2. cr.cr_ngroups is initialised to -1, and cr.cr_ngroups is checked
      for negative and overlarge values.
      
      This means that if the getsockopt() call returns success but doesn't
      actually update the xucred structure, this is now caught. This
      happened previously when getsockopt was called with SOL_SOCKET
      instead of SOL_LOCAL, prior to commit 5a468b38, and resulted in
      random uids being accepted.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      aa0f0992
  2. 16 10月, 2013 1 次提交
    • O
      rpc: Correct the wrong payload size checking · 0959785d
      Osier Yang 提交于
      <...>
      /* Size of message length field. Not counted in VIR_NET_MESSAGE_MAX
       * and VIR_NET_MESSAGE_INITIAL.
       */
      const VIR_NET_MESSAGE_LEN_MAX = 4;
      </...>
      
      However, msg->bufferLength includes the length word. The wrong checking
      was introduced by commit e914dcfd.
      
      * src/rpc/virnetmessage.c:
        - Correct the checking in virNetMessageEncodePayloadRaw
        - Use a new variable to track the new payload length in
          virNetMessageEncodePayloadRaw
      0959785d
  3. 11 10月, 2013 1 次提交
  4. 07 10月, 2013 2 次提交
    • C
      Adjust legacy max payload size to account for header information · 609eb987
      Claudio Bley 提交于
      Commit 27e81517 set the payload size to 256 KB, which is
      actually the max packet size, including the size of the header.
      
      Reduce this by VIR_NET_MESSAGE_HEADER_MAX (24) and set
      VIR_NET_MESSAGE_LEGACY_PAYLOAD_MAX to 262120, which was the original
      value before increasing the limit in commit eb635de1.
      609eb987
    • R
      rpc: fix getsockopt for LOCAL_PEERCRED on Mac OS X · 5a468b38
      Ryota Ozaki 提交于
      This fixes the following error:
        error : virGetUserEnt:703 : Failed to find user record for uid '32654'
      
      '32654' (it's random and varies) comes from getsockopt with
      LOCAL_PEERCRED option. getsockopt returns w/o error but seems
      to not set any value to the buffer for uid.
      
      For Mac OS X, LOCAL_PEERCRED has to be used with SOL_LOCAL level.
      With SOL_LOCAL, getsockopt returns a correct uid.
      
      Note that SOL_LOCAL can be found in
      /System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/un.h.
      Signed-off-by: NRyota Ozaki <ozaki.ryota@gmail.com>
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      5a468b38
  5. 01 10月, 2013 1 次提交
  6. 28 9月, 2013 3 次提交
  7. 24 9月, 2013 2 次提交
  8. 18 9月, 2013 1 次提交
  9. 05 9月, 2013 1 次提交
  10. 10 8月, 2013 1 次提交
  11. 09 8月, 2013 1 次提交
    • J
      virnettlscontext: Resolve Coverity warnings (UNINIT) · f905cc99
      John Ferlan 提交于
      Coverity complained about the usage of the uninitialized cacerts in the
      event(s) that "access(certFile, R_OK)" and/or "access(cacertFile, R_OK)"
      fail the for loop used to fill in the certs will have indeterminate data
      as well as the possibility that both failures would result in the
      gnutls_x509_crt_deinit() call having a similar fate.
      
      Initializing cacerts only would resolve the issue; however, it still
      would leave the indeterminate action, so rather add a parameter to
      the virNetTLSContextLoadCACertListFromFile() to pass the max size rather
      then overloading the returned count parameter. If the the call is never
      made, then we won't go through the for loops referencing the empty
      cacerts
      f905cc99
  12. 08 8月, 2013 2 次提交
    • D
      Add info about access control checks into API reference · 664ab280
      Daniel P. Berrange 提交于
      So that app developers / admins know what access control checks
      are performed for each API, this patch extends the API docs
      generator to include details of the ACLs for each.
      
      The gendispatch.pl script is extended so that it generates
      a simple XML describing ACL rules, eg.
      
        <aclinfo>
          ...
          <api name='virConnectNumOfDomains'>
            <check object='connect' perm='search_domains'/>
            <filter object='domain' perm='getattr'/>
          </api>
          <api name='virDomainAttachDeviceFlags'>
            <check object='domain' perm='write'/>
            <check object='domain' perm='save' flags='!VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE'/>
            <check object='domain' perm='save' flags='VIR_DOMAIN_AFFECT_CONFIG'/>
          </api>
          ...
        </aclinfo>
      
      The newapi.xsl template loads the XML files containing the ACL
      rules and generates a short block of HTML for each API describing
      the parameter checks and return value filters (if any).
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      664ab280
    • D
      Fix validation of CA certificate chains · 31d41d92
      Daniel P. Berrange 提交于
      The code added to validate CA certificates did not take into
      account the possibility that the cacert.pem file can contain
      multiple (concatenated) cert data blocks. Extend the code for
      loading CA certs to use the gnutls APIs for loading cert lists.
      Add test cases to check that multi-level trees of certs will
      validate correctly.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      31d41d92
  13. 05 8月, 2013 2 次提交
    • M
      Introduce max_queued_clients · 1199edb1
      Michal Privoznik 提交于
      This configuration knob lets user to set the length of queue of
      connection requests waiting to be accept()-ed by the daemon. IOW, it
      just controls the @backlog passed to listen:
      
        int listen(int sockfd, int backlog);
      1199edb1
    • M
      RPC: Don't accept client if it would overcommit max_clients · 2737aaaf
      Michal Privoznik 提交于
      Currently, even if max_client limit is hit, we accept() incoming
      connection request, but close it immediately. This has disadvantage of
      not using listen() queue. We should accept() only those clients we
      know we can serve and let all other wait in the (limited) queue.
      2737aaaf
  14. 12 7月, 2013 2 次提交
    • P
      remote: Improve libssh2 password authentication · 273745b4
      Peter Krempa 提交于
      This patch enables the password authentication in the libssh2 connection
      driver. There are a few benefits to this step:
      
      1) Hosts with challenge response authentication will now be supported
      with the libssh2 connection driver.
      
      2) Credential for hosts can now be stored in the authentication
      credential config file
      273745b4
    • P
      libssh2: Improve password based authentication · 676504e3
      Peter Krempa 提交于
      The password authentication method wasn't used as there wasn't a
      pleasant way to pass the password. This patch adds the option to use
      virAuth util functions to request the password either from a config file
      or uses the conf callback to request it from the user.
      676504e3
  15. 11 7月, 2013 1 次提交
  16. 10 7月, 2013 1 次提交
  17. 03 7月, 2013 1 次提交
  18. 24 6月, 2013 2 次提交
    • D
      Auto-generate helpers for checking access control rules · 68602622
      Daniel P. Berrange 提交于
      Extend the 'gendispatch.pl' script to be able to generate
      three new types of file.
      
      - 'aclheader' - defines signatures of helper APIs for
        doing authorization checks. There is one helper API
        for each API requiring an auth check. Any @acl
        annotations result in a method being generated with
        a suffix of 'EnsureACL'. If the ACL check requires
        examination of flags, an extra 'flags' param will be
        present. Some examples
      
        extern int virConnectBaselineCPUEnsureACL(void);
        extern int virConnectDomainEventDeregisterEnsureACL(virDomainDefPtr domain);
        extern int virDomainAttachDeviceFlagsEnsureACL(virDomainDefPtr domain, unsigned int flags);
      
        Any @aclfilter annotations resuilt in a method being
        generated with a suffix of 'CheckACL'.
      
        extern int virConnectListAllDomainsCheckACL(virDomainDefPtr domain);
      
        These are used for filtering individual objects from APIs
        which return a list of objects
      
      - 'aclbody' - defines the actual implementation of the
        methods described above. This calls into the access
        manager APIs. A complex example:
      
          /* Returns: -1 on error (denied==error), 0 on allowed */
          int virDomainAttachDeviceFlagsEnsureACL(virConnectPtr conn,
                                                  virDomainDefPtr domain,
                                                  unsigned int flags)
          {
              virAccessManagerPtr mgr;
              int rv;
      
              if (!(mgr = virAccessManagerGetDefault()))
                  return -1;
      
              if ((rv = virAccessManagerCheckDomain(mgr,
                                                    conn->driver->name,
                                                    domain,
                                                    VIR_ACCESS_PERM_DOMAIN_WRITE)) <= 0) {
                  virObjectUnref(mgr);
                  if (rv == 0)
                      virReportError(VIR_ERR_ACCESS_DENIED, NULL);
                  return -1;
              }
              if (((flags & (VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE)) == 0) &&
                  (rv = virAccessManagerCheckDomain(mgr,
                                                    conn->driver->name,
                                                    domain,
                                                    VIR_ACCESS_PERM_DOMAIN_SAVE)) <= 0) {
                  virObjectUnref(mgr);
                  if (rv == 0)
                      virReportError(VIR_ERR_ACCESS_DENIED, NULL);
                  return -1;
              }
              if (((flags & (VIR_DOMAIN_AFFECT_CONFIG)) == (VIR_DOMAIN_AFFECT_CONFIG)) &&
                  (rv = virAccessManagerCheckDomain(mgr,
                                                    conn->driver->name,
                                                    domain,
                                                    VIR_ACCESS_PERM_DOMAIN_SAVE)) <= 0) {
                  virObjectUnref(mgr);
                  if (rv == 0)
                      virReportError(VIR_ERR_ACCESS_DENIED, NULL);
                  return -1;
              }
              virObjectUnref(mgr);
              return 0;
          }
      
      - 'aclsyms' - generates a linker script to export the
         APIs to drivers. Some examples
      
        virConnectBaselineCPUEnsureACL;
        virConnectCompareCPUEnsureACL;
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      68602622
    • D
      Add ACL annotations to all RPC messages · e341435e
      Daniel P. Berrange 提交于
      Introduce annotations to all RPC messages to declare what
      access control checks are required. There are two new
      annotations defined:
      
       @acl: <object>:<permission>
       @acl: <object>:<permission>:<flagname>
      
        Declare the access control requirements for the API. May be repeated
        multiple times, if multiple rules are required.
      
          <object> is one of 'connect', 'domain', 'network', 'storagepool',
                   'interface', 'nodedev', 'secret'.
          <permission> is one of the permissions in access/viraccessperm.h
          <flagname> indicates the rule only applies if the named flag
          is set in the API call
      
       @aclfilter: <object>:<permission>
      
        Declare an access control filter that will be applied to a list
        of objects being returned by an API. This allows the returned
        list to be filtered to only show those the user has permissions
        against
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      e341435e
  19. 06 6月, 2013 1 次提交
  20. 30 5月, 2013 2 次提交
  21. 29 5月, 2013 1 次提交
    • E
      build: fix build with newer gnutls · 7d21d6b6
      Eric Blake 提交于
      Building with gnutls 3.2.0 (such as shipped with current cygwin) fails
      with:
      
      rpc/virnettlscontext.c: In function 'virNetTLSSessionGetKeySize':
      rpc/virnettlscontext.c:1358:5: error: implicit declaration of function 'gnutls_cipher_get_key_size' [-Wimplicit-function-declaration]
      
      Yeah, it's stupid that gnutls broke API by moving their declaration
      into a new header without including that header from the old one,
      but it's easy enough to work around, all without breaking on gnutls
      1.4.1 (hello RHEL 5) that lacked the new header.
      
      * configure.ac (gnutls): Check for <gnutls/crypto.h>.
      * src/rpc/virnettlscontext.c (includes): Include additional header.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      7d21d6b6
  22. 23 5月, 2013 3 次提交
  23. 22 5月, 2013 1 次提交
    • O
      syntax-check: Add the rule to forbid whitespace before ";" · ba0880b2
      Osier Yang 提交于
      Only a few cases are allowed:
      
      1) The expression is empty for "for" loop, E.g.
      
        for (i = 0; ; i++)
      
      2) An empty statement
      
        while (write(statuswrite, &status, 1) == -1 &&
               errno == EINTR)
            ; /* empty */
      
      3) ";" is inside double-quote, I.e, as part of const string. E.g.
      
        vshPrint(ctl, "a ; b ; cd;\n");
      
      The "for" loop in src/rpc/virnettlscontext.c is the special case,
      1) applies for it, so change it together in this patch.
      ba0880b2
  24. 21 5月, 2013 2 次提交
    • O
      src/rpc: Remove the whitespace before ";" · 13dbad40
      Osier Yang 提交于
      13dbad40
    • E
      maint: use LGPL correctly · d7f53c7b
      Eric Blake 提交于
      Several files called out COPYING or COPYING.LIB instead of using
      the normal boilerplate.  It's especially important that we don't
      call out COPYING from an LGPL file, since COPYING is traditionally
      used for the GPL.  A few files were lacking copyright altogether.
      
      * src/rpc/gendispatch.pl: Add missing copyright.
      * Makefile.nonreentrant: Likewise.
      * src/check-symfile.pl: Likewise.
      * src/check-symsorting.pl: Likewise.
      * src/driver.h: Likewise.
      * src/internal.h: Likewise.
      * tools/libvirt-guests.sh.in: Likewise.
      * tools/virt-pki-validate.in: Mention copyright in comment, not just code.
      * tools/virt-sanlock-cleanup.in: Likewise.
      * src/rpc/genprotocol.pl: Spell out license terms.
      * src/xen/xend_internal.h: Likewise.
      * src/xen/xend_internal.c: Likewise.
      * Makefile.am: Likewise.
      * daemon/Makefile.am: Likewise.
      * docs/Makefile.am: Likewise.
      * docs/schemas/Makefile.am: Likewise.
      * examples/apparmor/Makefile.am: Likewise.
      * examples/domain-events/events-c/Makefile.am: Likewise.
      * examples/dominfo/Makefile.am: Likewise.
      * examples/domsuspend/Makefile.am: Likewise.
      * examples/hellolibvirt/Makefile.am: Likewise.
      * examples/openauth/Makefile.am: Likewise.
      * examples/python/Makefile.am: Likewise.
      * examples/systemtap/Makefile.am: Likewise.
      * examples/xml/nwfilter/Makefile.am: Likewise.
      * gnulib/lib/Makefile.am: Likewise.
      * gnulib/tests/Makefile.am: Likewise.
      * include/Makefile.am: Likewise.
      * include/libvirt/Makefile.am: Likewise.
      * python/Makefile.am: Likewise.
      * python/tests/Makefile.am: Likewise.
      * src/Makefile.am: Likewise.
      * tests/Makefile.am: Likewise.
      * tools/Makefile.am: Likewise.
      * configure.ac: Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      d7f53c7b
  25. 11 5月, 2013 1 次提交
    • L
      util: move virFile* functions from virutil.c to virfile.c · bfe7721d
      Laine Stump 提交于
      These all existed before virfile.c was created, and for some reason
      weren't moved.
      
      This is mostly straightfoward, although the syntax rule prohibiting
      write() had to be changed to have an exception for virfile.c instead
      of virutil.c.
      
      This movement pointed out that there is a function called
      virBuildPath(), and another almost identical function called
      virFileBuildPath(). They really should be a single function, which
      I'll take care of as soon as I figure out what the arglist should look
      like.
      bfe7721d
  26. 08 5月, 2013 2 次提交
  27. 07 5月, 2013 1 次提交
    • D
      rpc: message related sizes enlarged · e914dcfd
      Daniel Hansel 提交于
      We have seen an issue on s390x platform where domain XMLs larger than 1MB
      were used. The define command was finished successfully. The dumpxml command
      was not successful (i.e. could not encode message payload).
      
      Enlarged message related sizes (e.g. maximum string size, message size, etc.)
      to handle larger system configurations used on s390x platform.
      
      To improve handling of the RPC message size the allocation during encode process
      is changed to a dynamic one (i.e. starting with 64kB initial size and increasing
      that size in steps up to 16MB if the payload data is larger).
      Signed-off-by: NDaniel Hansel <daniel.hansel@linux.vnet.ibm.com>
      Signed-off-by: NViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
      e914dcfd