summaryrefslogtreecommitdiff
path: root/doc/librpm/html/rpmkeys_8c_source.html
blob: 06cbf4cb0d74ca43b020a348a4072035b00cc1f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>rpm: rpmkeys.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.4 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">rpm&#160;<span id="projectnumber">4.9.1</span></div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">rpmkeys.c</div>  </div>
</div>
<div class="contents">
<a href="rpmkeys_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &quot;<a class="code" href="system_8h.html">system.h</a>&quot;</span>
<a name="l00002"></a>00002 
<a name="l00003"></a>00003 <span class="preprocessor">#include &lt;popt.h&gt;</span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &lt;rpm/rpmcli.h&gt;</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include &quot;<a class="code" href="cliutils_8h.html">cliutils.h</a>&quot;</span>
<a name="l00006"></a>00006 <span class="preprocessor">#include &quot;<a class="code" href="debug_8h.html">debug.h</a>&quot;</span>
<a name="l00007"></a>00007 
<a name="l00008"></a>00008 <span class="preprocessor">#if !defined(__GLIBC__) &amp;&amp; !defined(__APPLE__)</span>
<a name="l00009"></a><a class="code" href="rpmkeys_8c.html#aa006daaf11f1e2e45a6ababaf463212b">00009</a> <span class="preprocessor"></span><span class="keywordtype">char</span> ** <a class="code" href="rpmdb_8c.html#aa006daaf11f1e2e45a6ababaf463212b">environ</a> = NULL;
<a name="l00010"></a>00010 <span class="preprocessor">#endif</span>
<a name="l00011"></a>00011 <span class="preprocessor"></span>
<a name="l00012"></a><a class="code" href="rpmkeys_8c.html#a811fe196a5d9d37857c2f8adeeaac3c6">00012</a> <span class="keyword">enum</span> <a class="code" href="rpmbuild_8c.html#a811fe196a5d9d37857c2f8adeeaac3c6">modes</a> {
<a name="l00013"></a><a class="code" href="rpmkeys_8c.html#a811fe196a5d9d37857c2f8adeeaac3c6a6e71f3470e43602dd881d1cb0ce779a0">00013</a>     <a class="code" href="rpmkeys_8c.html#a811fe196a5d9d37857c2f8adeeaac3c6a6e71f3470e43602dd881d1cb0ce779a0">MODE_CHECKSIG</a>       = (1 &lt;&lt; 0),
<a name="l00014"></a><a class="code" href="rpmkeys_8c.html#a811fe196a5d9d37857c2f8adeeaac3c6ad3de96dfd77735bff12609801e957068">00014</a>     <a class="code" href="rpmkeys_8c.html#a811fe196a5d9d37857c2f8adeeaac3c6ad3de96dfd77735bff12609801e957068">MODE_IMPORTKEY</a>      = (1 &lt;&lt; 1),
<a name="l00015"></a><a class="code" href="rpmkeys_8c.html#a811fe196a5d9d37857c2f8adeeaac3c6aa18ebfe027af5690e69c8a3aa70624fe">00015</a>     <a class="code" href="rpmkeys_8c.html#a811fe196a5d9d37857c2f8adeeaac3c6aa18ebfe027af5690e69c8a3aa70624fe">MODE_DELKEY</a>         = (1 &lt;&lt; 2),
<a name="l00016"></a><a class="code" href="rpmkeys_8c.html#a811fe196a5d9d37857c2f8adeeaac3c6a89643e161cf5df1984e15c4ce855dd9b">00016</a>     <a class="code" href="rpmkeys_8c.html#a811fe196a5d9d37857c2f8adeeaac3c6a89643e161cf5df1984e15c4ce855dd9b">MODE_LISTKEY</a>        = (1 &lt;&lt; 3),
<a name="l00017"></a>00017 };
<a name="l00018"></a>00018 
<a name="l00019"></a><a class="code" href="rpmkeys_8c.html#a1ea5d0cb93f22f7d0fdf804bd68c3326">00019</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="rpmkeys_8c.html#a1ea5d0cb93f22f7d0fdf804bd68c3326">mode</a> = 0;
<a name="l00020"></a>00020 
<a name="l00021"></a><a class="code" href="rpmkeys_8c.html#a5baf570a3741ad40911ae528d92441ee">00021</a> <span class="keyword">static</span> <span class="keyword">struct </span>poptOption <a class="code" href="rpmkeys_8c.html#a5baf570a3741ad40911ae528d92441ee">keyOptsTable</a>[] = {
<a name="l00022"></a>00022     { <span class="stringliteral">&quot;checksig&quot;</span>, <span class="charliteral">&#39;K&#39;</span>, (POPT_ARG_VAL|POPT_ARGFLAG_OR), &amp;mode, <a class="code" href="rpmkeys_8c.html#a811fe196a5d9d37857c2f8adeeaac3c6a6e71f3470e43602dd881d1cb0ce779a0">MODE_CHECKSIG</a>,
<a name="l00023"></a>00023         <a class="code" href="system_8h.html#aca24492e24b07d15df23b4957092a9f3">N_</a>(<span class="stringliteral">&quot;verify package signature(s)&quot;</span>), NULL },
<a name="l00024"></a>00024     { <span class="stringliteral">&quot;import&quot;</span>, <span class="charliteral">&#39;\0&#39;</span>, (POPT_ARG_VAL|POPT_ARGFLAG_OR), &amp;mode, <a class="code" href="rpmkeys_8c.html#a811fe196a5d9d37857c2f8adeeaac3c6ad3de96dfd77735bff12609801e957068">MODE_IMPORTKEY</a>,
<a name="l00025"></a>00025         <a class="code" href="system_8h.html#aca24492e24b07d15df23b4957092a9f3">N_</a>(<span class="stringliteral">&quot;import an armored public key&quot;</span>), NULL },
<a name="l00026"></a>00026 <span class="preprocessor">#if 0</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span>    { <span class="stringliteral">&quot;delete-key&quot;</span>, <span class="charliteral">&#39;\0&#39;</span>, (POPT_ARG_VAL|POPT_ARGFLAG_OR), &amp;mode, <a class="code" href="rpmkeys_8c.html#a811fe196a5d9d37857c2f8adeeaac3c6aa18ebfe027af5690e69c8a3aa70624fe">MODE_DELKEY</a>,
<a name="l00028"></a>00028         <a class="code" href="system_8h.html#aca24492e24b07d15df23b4957092a9f3">N_</a>(<span class="stringliteral">&quot;list keys from RPM keyring&quot;</span>), NULL },
<a name="l00029"></a>00029     { <span class="stringliteral">&quot;list-keys&quot;</span>, <span class="charliteral">&#39;\0&#39;</span>, (POPT_ARG_VAL|POPT_ARGFLAG_OR), &amp;mode, <a class="code" href="rpmkeys_8c.html#a811fe196a5d9d37857c2f8adeeaac3c6a89643e161cf5df1984e15c4ce855dd9b">MODE_LISTKEY</a>,
<a name="l00030"></a>00030         <a class="code" href="system_8h.html#aca24492e24b07d15df23b4957092a9f3">N_</a>(<span class="stringliteral">&quot;list keys from RPM keyring&quot;</span>), NULL },
<a name="l00031"></a>00031 <span class="preprocessor">#endif</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span>    POPT_TABLEEND
<a name="l00033"></a>00033 };
<a name="l00034"></a>00034 
<a name="l00035"></a><a class="code" href="rpmkeys_8c.html#a779c8fb41edee9b03a02a249606b0e76">00035</a> <span class="keyword">static</span> <span class="keyword">struct </span>poptOption <a class="code" href="rpmkeys_8c.html#a779c8fb41edee9b03a02a249606b0e76">optionsTable</a>[] = {
<a name="l00036"></a>00036     { NULL, <span class="charliteral">&#39;\0&#39;</span>, POPT_ARG_INCLUDE_TABLE, <a class="code" href="rpmkeys_8c.html#a5baf570a3741ad40911ae528d92441ee">keyOptsTable</a>, 0,
<a name="l00037"></a>00037         <a class="code" href="system_8h.html#aca24492e24b07d15df23b4957092a9f3">N_</a>(<span class="stringliteral">&quot;Keyring options:&quot;</span>), NULL },
<a name="l00038"></a>00038     { NULL, <span class="charliteral">&#39;\0&#39;</span>, POPT_ARG_INCLUDE_TABLE, <a class="code" href="group__rpmcli.html#ga60bd8b746df91eb1824a7ad6ffd42cf1" title="Popt option table for options shared by all modes and executables.">rpmcliAllPoptTable</a>, 0,
<a name="l00039"></a>00039         <a class="code" href="system_8h.html#aca24492e24b07d15df23b4957092a9f3">N_</a>(<span class="stringliteral">&quot;Common options for all rpm modes and executables:&quot;</span>), NULL },
<a name="l00040"></a>00040 
<a name="l00041"></a>00041     POPT_AUTOALIAS
<a name="l00042"></a>00042     POPT_AUTOHELP
<a name="l00043"></a>00043     POPT_TABLEEND
<a name="l00044"></a>00044 };
<a name="l00045"></a>00045 
<a name="l00046"></a><a class="code" href="rpmkeys_8c.html#a0ddf1224851353fc92bfbff6f499fa97">00046</a> <span class="keywordtype">int</span> <a class="code" href="rpm2cpio_8c.html#a0ddf1224851353fc92bfbff6f499fa97">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])
<a name="l00047"></a>00047 {
<a name="l00048"></a>00048     <span class="keywordtype">int</span> ec = EXIT_FAILURE;
<a name="l00049"></a>00049     poptContext optCon = <a class="code" href="group__rpmcli.html#gaf4d555b4c5efcf319fe643d164775eaf" title="Initialize most everything needed by an rpm CLI executable context.">rpmcliInit</a>(argc, argv, optionsTable);
<a name="l00050"></a>00050     <a class="code" href="group__rpmtypes.html#ga1a512138316a227059ca128597dbd464" title="The main types involved in transaction manipulation.">rpmts</a> ts = <a class="code" href="group__rpmts.html#gace47f4eaebd8be4f0abbcfb7942b3566" title="Create an empty transaction set.">rpmtsCreate</a>();
<a name="l00051"></a>00051     <a class="code" href="argv_8h.html#a6c416352f01820f9a95d3d9cc21e93e9">ARGV_const_t</a> args = NULL;
<a name="l00052"></a>00052     
<a name="l00053"></a>00053     <span class="keywordflow">if</span> (argc &lt; 2) {
<a name="l00054"></a>00054         <a class="code" href="cliutils_8c.html#a4a1ef17fed649a0761310301053e97ed">printUsage</a>(optCon, stderr, 0);
<a name="l00055"></a>00055         <span class="keywordflow">goto</span> exit;
<a name="l00056"></a>00056     }
<a name="l00057"></a>00057 
<a name="l00058"></a>00058     args = (<a class="code" href="argv_8h.html#a6c416352f01820f9a95d3d9cc21e93e9">ARGV_const_t</a>) poptGetArgs(optCon);
<a name="l00059"></a>00059 
<a name="l00060"></a>00060     <span class="keywordflow">if</span> (mode != <a class="code" href="rpmkeys_8c.html#a811fe196a5d9d37857c2f8adeeaac3c6a89643e161cf5df1984e15c4ce855dd9b">MODE_LISTKEY</a> &amp;&amp; args == NULL)
<a name="l00061"></a>00061         <a class="code" href="cliutils_8c.html#a04b3e702e4cded860c0e1c9bb6f104ed">argerror</a>(<a class="code" href="system_8h.html#a8a97de23397d8af6821824c0234d8c3c">_</a>(<span class="stringliteral">&quot;no arguments given&quot;</span>));
<a name="l00062"></a>00062 
<a name="l00063"></a>00063     <a class="code" href="group__rpmts.html#ga2cc54aa978a49d0b5cefa64095c8ee41" title="Set transaction rootDir, i.e.">rpmtsSetRootDir</a>(ts, <a class="code" href="rpmcli_8h.html#a4a1b016e2d7aaea6937155c21c87a215">rpmcliRootDir</a>);
<a name="l00064"></a>00064 
<a name="l00065"></a>00065     <span class="keywordflow">switch</span> (mode) {
<a name="l00066"></a>00066     <span class="keywordflow">case</span> <a class="code" href="rpmkeys_8c.html#a811fe196a5d9d37857c2f8adeeaac3c6a6e71f3470e43602dd881d1cb0ce779a0">MODE_CHECKSIG</a>:
<a name="l00067"></a>00067         ec = <a class="code" href="group__rpmcli.html#ga0b2d1383b10c5aa7ce7155275f035b38" title="Verify package signatures.">rpmcliVerifySignatures</a>(ts, args);
<a name="l00068"></a>00068         <span class="keywordflow">break</span>;
<a name="l00069"></a>00069     <span class="keywordflow">case</span> <a class="code" href="rpmkeys_8c.html#a811fe196a5d9d37857c2f8adeeaac3c6ad3de96dfd77735bff12609801e957068">MODE_IMPORTKEY</a>:
<a name="l00070"></a>00070         ec = <a class="code" href="rpmcli_8h.html#a6b09ad8eb4f2251a1635199602614db5" title="Import public key(s) to rpm keyring.">rpmcliImportPubkeys</a>(ts, args);
<a name="l00071"></a>00071         <span class="keywordflow">break</span>;
<a name="l00072"></a>00072     <span class="comment">/* XXX TODO: actually implement these... */</span>
<a name="l00073"></a>00073     <span class="keywordflow">case</span> <a class="code" href="rpmkeys_8c.html#a811fe196a5d9d37857c2f8adeeaac3c6aa18ebfe027af5690e69c8a3aa70624fe">MODE_DELKEY</a>:
<a name="l00074"></a>00074     <span class="keywordflow">case</span> <a class="code" href="rpmkeys_8c.html#a811fe196a5d9d37857c2f8adeeaac3c6a89643e161cf5df1984e15c4ce855dd9b">MODE_LISTKEY</a>:
<a name="l00075"></a>00075         <span class="keywordflow">break</span>;
<a name="l00076"></a>00076     <span class="keywordflow">default</span>:
<a name="l00077"></a>00077         <a class="code" href="cliutils_8c.html#a04b3e702e4cded860c0e1c9bb6f104ed">argerror</a>(<a class="code" href="system_8h.html#a8a97de23397d8af6821824c0234d8c3c">_</a>(<span class="stringliteral">&quot;only one major mode may be specified&quot;</span>));
<a name="l00078"></a>00078     }
<a name="l00079"></a>00079 
<a name="l00080"></a>00080 exit:
<a name="l00081"></a>00081     <a class="code" href="group__rpmts.html#ga5315165a6e80a0c71dbe5eb07dd18f58" title="Destroy transaction set, closing the database as well.">rpmtsFree</a>(ts);
<a name="l00082"></a>00082     <a class="code" href="group__rpmcli.html#ga9b4197af25cc216aa3bb7cce5d158dcf" title="Destroy most everything needed by an rpm CLI executable context.">rpmcliFini</a>(optCon);
<a name="l00083"></a>00083     <span class="keywordflow">return</span> ec;
<a name="l00084"></a>00084 }
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Fri Jul 15 2011 for rpm by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>