2003-04-29 22:34:46 +00:00
|
|
|
|
/* trust-item.c - Trust item objects.
|
|
|
|
|
Copyright (C) 2000 Werner Koch (dd9jn)
|
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README: Refer to COPYING.LESSER and "each file" instead of
COPYING.
* COPYING.LESSER: New file.
* gpgme.spec.in (%doc): Add COPYING.LESSER.
* acinclude.m4, configure.ac, Makefile.am: Change license to LGPL
2.1 or later.
* TODO: Add copyright notice.
* README.CVS: Likewise.
assuan/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README.1st: Add copyright notice.
doc/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am: Change license to LGPL.
(gpgme_TEXINFOS): Replace gpl.texi with lesser.texi.
* gpgme.texi: Change license to LGPL (also for documentation of
GPGME's license).
* lesser.texi: New file.
* gpl.texi: File removed.
gpgme/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* putc_unlocked.c, funopen.c: I just claim copyright on these
files and change their license to LGPL, because they are totally
trivial wrapper functions.
* isascii.c: Change copyright notice to the one from ctype/ctype.h
in the GNU C Library (CVS Head 2004-10-10), where isascii is
defined as a macro doing exactly the same as the function in this
file.
* memrchr.c: Update from the GNU C Library (CVS Head 2001-07-06).
* stpcpy.c: Update from the GNU C Library (CVS Head 2004-10-10).
* ath.c, ath-compat.c, ath.h, ath-pth.c, ath-pth-compat.c,
ath-pthread.c, ath-pthread-compat.c, context.h, conversion.c,
data.c, data-compat.c, data-fd.c, data.h, data-mem.c,
data-stream.c, data-user.c, debug.c, debug.h, decrypt.c,
decrypt-verify.c, delete.c, edit.c, encrypt.c, encrypt-sign.c,
engine-backend.h, engine.c, engine-gpgsm.c, engine.h, error.c,
export.c, genkey.c, get-env.c, gpgme.c, gpgme.h, import.c, io.h,
key.c, keylist.c, mkstatus, Makefile.am, ops.h, op-support.c,
passphrase.c, posix-io.c, posix-sema.c, posix-util.c, progress.c,
rungpg.c, sema.h, sign.c, signers.c, trust-item.c, trustlist.c,
util.h, verify.c, version.c, w32-io.c, w32-sema.c, w32-util.c,
wait.c, wait-global.c, wait.h, wait-private.c, wait-user.c: Change
license to LGPL.
tests/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* gpg/mkdemodirs: Add copyright notice.
* gpgsm/Makefile.am, gpgsm/t-support.h, gpgsm/t-decrypt.c,
gpgsm/t-encrypt.c, gpgsm/t-export.c, gpgsm/t-genkey.c,
gpgsm/t-import.c, gpgsm/t-keylist.c, gpgsm/t-sign.c,
gpgsm/t-verify.c, gpg/Makefile.am, gpg/t-decrypt.c,
gpg/t-decrypt-verify.c, gpg/t-edit.c, gpg/t-encrypt.c,
gpg/t-encrypt-sign.c, gpg/t-encrypt-sym.c, gpg/t-eventloop.c,
gpg/t-export.c, gpg/t-genkey.c, gpg/t-import.c, gpg/t-keylist.c,
gpg/t-keylist-sig.c, gpg/t-sign.c, gpg/t-signers.c,
gpg/t-support.h, gpg/t-thread1.c, gpg/t-trustlist.c,
gpg/t-verify.c, Makefile.am, t-data.c, t-engine-info.c,
t-version.c: Change license to LGPL.
2004-12-07 21:13:39 +00:00
|
|
|
|
Copyright (C) 2001, 2002, 2003, 2004 g10 Code GmbH
|
2003-04-29 22:34:46 +00:00
|
|
|
|
|
|
|
|
|
This file is part of GPGME.
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2003-04-29 22:34:46 +00:00
|
|
|
|
GPGME is free software; you can redistribute it and/or modify it
|
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README: Refer to COPYING.LESSER and "each file" instead of
COPYING.
* COPYING.LESSER: New file.
* gpgme.spec.in (%doc): Add COPYING.LESSER.
* acinclude.m4, configure.ac, Makefile.am: Change license to LGPL
2.1 or later.
* TODO: Add copyright notice.
* README.CVS: Likewise.
assuan/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README.1st: Add copyright notice.
doc/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am: Change license to LGPL.
(gpgme_TEXINFOS): Replace gpl.texi with lesser.texi.
* gpgme.texi: Change license to LGPL (also for documentation of
GPGME's license).
* lesser.texi: New file.
* gpl.texi: File removed.
gpgme/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* putc_unlocked.c, funopen.c: I just claim copyright on these
files and change their license to LGPL, because they are totally
trivial wrapper functions.
* isascii.c: Change copyright notice to the one from ctype/ctype.h
in the GNU C Library (CVS Head 2004-10-10), where isascii is
defined as a macro doing exactly the same as the function in this
file.
* memrchr.c: Update from the GNU C Library (CVS Head 2001-07-06).
* stpcpy.c: Update from the GNU C Library (CVS Head 2004-10-10).
* ath.c, ath-compat.c, ath.h, ath-pth.c, ath-pth-compat.c,
ath-pthread.c, ath-pthread-compat.c, context.h, conversion.c,
data.c, data-compat.c, data-fd.c, data.h, data-mem.c,
data-stream.c, data-user.c, debug.c, debug.h, decrypt.c,
decrypt-verify.c, delete.c, edit.c, encrypt.c, encrypt-sign.c,
engine-backend.h, engine.c, engine-gpgsm.c, engine.h, error.c,
export.c, genkey.c, get-env.c, gpgme.c, gpgme.h, import.c, io.h,
key.c, keylist.c, mkstatus, Makefile.am, ops.h, op-support.c,
passphrase.c, posix-io.c, posix-sema.c, posix-util.c, progress.c,
rungpg.c, sema.h, sign.c, signers.c, trust-item.c, trustlist.c,
util.h, verify.c, version.c, w32-io.c, w32-sema.c, w32-util.c,
wait.c, wait-global.c, wait.h, wait-private.c, wait-user.c: Change
license to LGPL.
tests/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* gpg/mkdemodirs: Add copyright notice.
* gpgsm/Makefile.am, gpgsm/t-support.h, gpgsm/t-decrypt.c,
gpgsm/t-encrypt.c, gpgsm/t-export.c, gpgsm/t-genkey.c,
gpgsm/t-import.c, gpgsm/t-keylist.c, gpgsm/t-sign.c,
gpgsm/t-verify.c, gpg/Makefile.am, gpg/t-decrypt.c,
gpg/t-decrypt-verify.c, gpg/t-edit.c, gpg/t-encrypt.c,
gpg/t-encrypt-sign.c, gpg/t-encrypt-sym.c, gpg/t-eventloop.c,
gpg/t-export.c, gpg/t-genkey.c, gpg/t-import.c, gpg/t-keylist.c,
gpg/t-keylist-sig.c, gpg/t-sign.c, gpg/t-signers.c,
gpg/t-support.h, gpg/t-thread1.c, gpg/t-trustlist.c,
gpg/t-verify.c, Makefile.am, t-data.c, t-engine-info.c,
t-version.c: Change license to LGPL.
2004-12-07 21:13:39 +00:00
|
|
|
|
under the terms of the GNU Lesser General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2.1 of
|
|
|
|
|
the License, or (at your option) any later version.
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2003-04-29 22:34:46 +00:00
|
|
|
|
GPGME is distributed in the hope that it will be useful, but
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README: Refer to COPYING.LESSER and "each file" instead of
COPYING.
* COPYING.LESSER: New file.
* gpgme.spec.in (%doc): Add COPYING.LESSER.
* acinclude.m4, configure.ac, Makefile.am: Change license to LGPL
2.1 or later.
* TODO: Add copyright notice.
* README.CVS: Likewise.
assuan/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README.1st: Add copyright notice.
doc/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am: Change license to LGPL.
(gpgme_TEXINFOS): Replace gpl.texi with lesser.texi.
* gpgme.texi: Change license to LGPL (also for documentation of
GPGME's license).
* lesser.texi: New file.
* gpl.texi: File removed.
gpgme/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* putc_unlocked.c, funopen.c: I just claim copyright on these
files and change their license to LGPL, because they are totally
trivial wrapper functions.
* isascii.c: Change copyright notice to the one from ctype/ctype.h
in the GNU C Library (CVS Head 2004-10-10), where isascii is
defined as a macro doing exactly the same as the function in this
file.
* memrchr.c: Update from the GNU C Library (CVS Head 2001-07-06).
* stpcpy.c: Update from the GNU C Library (CVS Head 2004-10-10).
* ath.c, ath-compat.c, ath.h, ath-pth.c, ath-pth-compat.c,
ath-pthread.c, ath-pthread-compat.c, context.h, conversion.c,
data.c, data-compat.c, data-fd.c, data.h, data-mem.c,
data-stream.c, data-user.c, debug.c, debug.h, decrypt.c,
decrypt-verify.c, delete.c, edit.c, encrypt.c, encrypt-sign.c,
engine-backend.h, engine.c, engine-gpgsm.c, engine.h, error.c,
export.c, genkey.c, get-env.c, gpgme.c, gpgme.h, import.c, io.h,
key.c, keylist.c, mkstatus, Makefile.am, ops.h, op-support.c,
passphrase.c, posix-io.c, posix-sema.c, posix-util.c, progress.c,
rungpg.c, sema.h, sign.c, signers.c, trust-item.c, trustlist.c,
util.h, verify.c, version.c, w32-io.c, w32-sema.c, w32-util.c,
wait.c, wait-global.c, wait.h, wait-private.c, wait-user.c: Change
license to LGPL.
tests/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* gpg/mkdemodirs: Add copyright notice.
* gpgsm/Makefile.am, gpgsm/t-support.h, gpgsm/t-decrypt.c,
gpgsm/t-encrypt.c, gpgsm/t-export.c, gpgsm/t-genkey.c,
gpgsm/t-import.c, gpgsm/t-keylist.c, gpgsm/t-sign.c,
gpgsm/t-verify.c, gpg/Makefile.am, gpg/t-decrypt.c,
gpg/t-decrypt-verify.c, gpg/t-edit.c, gpg/t-encrypt.c,
gpg/t-encrypt-sign.c, gpg/t-encrypt-sym.c, gpg/t-eventloop.c,
gpg/t-export.c, gpg/t-genkey.c, gpg/t-import.c, gpg/t-keylist.c,
gpg/t-keylist-sig.c, gpg/t-sign.c, gpg/t-signers.c,
gpg/t-support.h, gpg/t-thread1.c, gpg/t-trustlist.c,
gpg/t-verify.c, Makefile.am, t-data.c, t-engine-info.c,
t-version.c: Change license to LGPL.
2004-12-07 21:13:39 +00:00
|
|
|
|
Lesser General Public License for more details.
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README: Refer to COPYING.LESSER and "each file" instead of
COPYING.
* COPYING.LESSER: New file.
* gpgme.spec.in (%doc): Add COPYING.LESSER.
* acinclude.m4, configure.ac, Makefile.am: Change license to LGPL
2.1 or later.
* TODO: Add copyright notice.
* README.CVS: Likewise.
assuan/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README.1st: Add copyright notice.
doc/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am: Change license to LGPL.
(gpgme_TEXINFOS): Replace gpl.texi with lesser.texi.
* gpgme.texi: Change license to LGPL (also for documentation of
GPGME's license).
* lesser.texi: New file.
* gpl.texi: File removed.
gpgme/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* putc_unlocked.c, funopen.c: I just claim copyright on these
files and change their license to LGPL, because they are totally
trivial wrapper functions.
* isascii.c: Change copyright notice to the one from ctype/ctype.h
in the GNU C Library (CVS Head 2004-10-10), where isascii is
defined as a macro doing exactly the same as the function in this
file.
* memrchr.c: Update from the GNU C Library (CVS Head 2001-07-06).
* stpcpy.c: Update from the GNU C Library (CVS Head 2004-10-10).
* ath.c, ath-compat.c, ath.h, ath-pth.c, ath-pth-compat.c,
ath-pthread.c, ath-pthread-compat.c, context.h, conversion.c,
data.c, data-compat.c, data-fd.c, data.h, data-mem.c,
data-stream.c, data-user.c, debug.c, debug.h, decrypt.c,
decrypt-verify.c, delete.c, edit.c, encrypt.c, encrypt-sign.c,
engine-backend.h, engine.c, engine-gpgsm.c, engine.h, error.c,
export.c, genkey.c, get-env.c, gpgme.c, gpgme.h, import.c, io.h,
key.c, keylist.c, mkstatus, Makefile.am, ops.h, op-support.c,
passphrase.c, posix-io.c, posix-sema.c, posix-util.c, progress.c,
rungpg.c, sema.h, sign.c, signers.c, trust-item.c, trustlist.c,
util.h, verify.c, version.c, w32-io.c, w32-sema.c, w32-util.c,
wait.c, wait-global.c, wait.h, wait-private.c, wait-user.c: Change
license to LGPL.
tests/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* gpg/mkdemodirs: Add copyright notice.
* gpgsm/Makefile.am, gpgsm/t-support.h, gpgsm/t-decrypt.c,
gpgsm/t-encrypt.c, gpgsm/t-export.c, gpgsm/t-genkey.c,
gpgsm/t-import.c, gpgsm/t-keylist.c, gpgsm/t-sign.c,
gpgsm/t-verify.c, gpg/Makefile.am, gpg/t-decrypt.c,
gpg/t-decrypt-verify.c, gpg/t-edit.c, gpg/t-encrypt.c,
gpg/t-encrypt-sign.c, gpg/t-encrypt-sym.c, gpg/t-eventloop.c,
gpg/t-export.c, gpg/t-genkey.c, gpg/t-import.c, gpg/t-keylist.c,
gpg/t-keylist-sig.c, gpg/t-sign.c, gpg/t-signers.c,
gpg/t-support.h, gpg/t-thread1.c, gpg/t-trustlist.c,
gpg/t-verify.c, Makefile.am, t-data.c, t-engine-info.c,
t-version.c: Change license to LGPL.
2004-12-07 21:13:39 +00:00
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
License along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
|
02111-1307, USA. */
|
2003-04-29 22:34:46 +00:00
|
|
|
|
|
|
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <assert.h>
|
2003-06-05 23:20:29 +00:00
|
|
|
|
#include <errno.h>
|
2003-04-29 22:34:46 +00:00
|
|
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
|
#include "ops.h"
|
|
|
|
|
#include "sema.h"
|
2012-10-19 09:23:39 +00:00
|
|
|
|
#include "debug.h"
|
2003-04-29 22:34:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Protects all reference counters in trust items. All other accesses
|
|
|
|
|
to a trust item are either read only or happen before the trust
|
|
|
|
|
item is available to the user. */
|
|
|
|
|
DEFINE_STATIC_LOCK (trust_item_ref_lock);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Create a new trust item. */
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_error_t
|
|
|
|
|
_gpgme_trust_item_new (gpgme_trust_item_t *r_item)
|
2003-04-29 22:34:46 +00:00
|
|
|
|
{
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_trust_item_t item;
|
2003-04-29 22:34:46 +00:00
|
|
|
|
|
|
|
|
|
item = calloc (1, sizeof *item);
|
|
|
|
|
if (!item)
|
2013-02-06 16:35:40 +00:00
|
|
|
|
return gpg_error_from_syserror ();
|
2003-04-29 22:34:46 +00:00
|
|
|
|
item->_refs = 1;
|
|
|
|
|
item->keyid = item->_keyid;
|
|
|
|
|
item->_keyid[16] = '\0';
|
2003-04-30 03:02:50 +00:00
|
|
|
|
item->owner_trust = item->_owner_trust;
|
|
|
|
|
item->_owner_trust[1] = '\0';
|
|
|
|
|
item->validity = item->_validity;
|
|
|
|
|
item->_validity[1] = '\0';
|
2003-04-29 22:34:46 +00:00
|
|
|
|
*r_item = item;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Acquire a reference to ITEM. */
|
|
|
|
|
void
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_trust_item_ref (gpgme_trust_item_t item)
|
2003-04-29 22:34:46 +00:00
|
|
|
|
{
|
|
|
|
|
LOCK (trust_item_ref_lock);
|
|
|
|
|
item->_refs++;
|
|
|
|
|
UNLOCK (trust_item_ref_lock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* gpgme_trust_item_unref releases the trust item object. Note that
|
|
|
|
|
this function may not do an actual release if there are other
|
|
|
|
|
shallow copies of the object. You have to call this function for
|
|
|
|
|
every newly created trust item object as well as for every
|
|
|
|
|
gpgme_trust_item_ref() done on the trust item object. */
|
|
|
|
|
void
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_trust_item_unref (gpgme_trust_item_t item)
|
2003-04-29 22:34:46 +00:00
|
|
|
|
{
|
|
|
|
|
LOCK (trust_item_ref_lock);
|
|
|
|
|
assert (item->_refs > 0);
|
|
|
|
|
if (--item->_refs)
|
|
|
|
|
{
|
|
|
|
|
UNLOCK (trust_item_ref_lock);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
UNLOCK (trust_item_ref_lock);
|
|
|
|
|
|
|
|
|
|
if (item->name)
|
|
|
|
|
free (item->name);
|
|
|
|
|
free (item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Compatibility interfaces. */
|
|
|
|
|
void
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_trust_item_release (gpgme_trust_item_t item)
|
2003-04-29 22:34:46 +00:00
|
|
|
|
{
|
|
|
|
|
gpgme_trust_item_unref (item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return the value of the attribute WHAT of ITEM, which has to be
|
|
|
|
|
representable by a string. */
|
2003-05-18 20:45:24 +00:00
|
|
|
|
const char *gpgme_trust_item_get_string_attr (gpgme_trust_item_t item,
|
|
|
|
|
_gpgme_attr_t what,
|
2003-04-29 22:34:46 +00:00
|
|
|
|
const void *reserved, int idx)
|
|
|
|
|
{
|
|
|
|
|
const char *val = NULL;
|
|
|
|
|
|
|
|
|
|
if (!item)
|
|
|
|
|
return NULL;
|
|
|
|
|
if (reserved)
|
|
|
|
|
return NULL;
|
|
|
|
|
if (idx)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
switch (what)
|
|
|
|
|
{
|
|
|
|
|
case GPGME_ATTR_KEYID:
|
|
|
|
|
val = item->keyid;
|
|
|
|
|
break;
|
|
|
|
|
|
2012-09-25 13:29:49 +00:00
|
|
|
|
case GPGME_ATTR_OTRUST:
|
2003-04-30 03:02:50 +00:00
|
|
|
|
val = item->owner_trust;
|
2003-04-29 22:34:46 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GPGME_ATTR_VALIDITY:
|
2003-04-30 03:02:50 +00:00
|
|
|
|
val = item->validity;
|
2003-04-29 22:34:46 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2012-09-25 13:29:49 +00:00
|
|
|
|
case GPGME_ATTR_USERID:
|
2003-04-29 22:34:46 +00:00
|
|
|
|
val = item->name;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Return the value of the attribute WHAT of KEY, which has to be
|
|
|
|
|
representable by an integer. IDX specifies a running index if the
|
|
|
|
|
attribute appears more than once in the key. */
|
2003-05-18 20:45:24 +00:00
|
|
|
|
int gpgme_trust_item_get_int_attr (gpgme_trust_item_t item, _gpgme_attr_t what,
|
2003-04-29 22:34:46 +00:00
|
|
|
|
const void *reserved, int idx)
|
|
|
|
|
{
|
|
|
|
|
int val = 0;
|
|
|
|
|
|
|
|
|
|
if (!item)
|
|
|
|
|
return 0;
|
|
|
|
|
if (reserved)
|
|
|
|
|
return 0;
|
|
|
|
|
if (idx)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
switch (what)
|
|
|
|
|
{
|
2012-09-25 13:29:49 +00:00
|
|
|
|
case GPGME_ATTR_LEVEL:
|
2003-04-29 22:34:46 +00:00
|
|
|
|
val = item->level;
|
|
|
|
|
break;
|
|
|
|
|
|
2012-09-25 13:29:49 +00:00
|
|
|
|
case GPGME_ATTR_TYPE:
|
2003-04-29 22:34:46 +00:00
|
|
|
|
val = item->type;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return val;
|
|
|
|
|
}
|