Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 164523
Collapse All | Expand All

(-)seahorse-0.8.2.org/agent/seahorse-agent-actions.c (-6 / +20 lines)
Lines 67-73 seahorse_agent_actions_uninit () Link Here
67
67
68
/* Called for the assuan GET_PASSPHRASE command */
68
/* Called for the assuan GET_PASSPHRASE command */
69
void
69
void
70
seahorse_agent_actions_getpass (SeahorseAgentConn * rq, gchar * id,
70
seahorse_agent_actions_getpass (SeahorseAgentConn * rq, gboolean pass_as_data, gchar * id,
71
                                gchar * errmsg, gchar * prompt, gchar * desc)
71
                                gchar * errmsg, gchar * prompt, gchar * desc)
72
{
72
{
73
    SeahorseAgentPassReq *pr;
73
    SeahorseAgentPassReq *pr;
Lines 80-87 seahorse_agent_actions_getpass (Seahorse Link Here
80
         * We don't need authorization, so if we have the password
80
         * We don't need authorization, so if we have the password
81
         * just reply now, without going to the queue.
81
         * just reply now, without going to the queue.
82
         */
82
         */
83
        if ((pass = seahorse_agent_cache_get (id)) != NULL) {
83
        if ((pass = seahorse_agent_cache_get (pass_as_data, id)) != NULL) {
84
            seahorse_agent_io_reply (rq, TRUE, pass);
84
	    if (pass_as_data) {
85
	            seahorse_agent_io_data (rq, pass);
86
	            seahorse_agent_io_reply (rq, TRUE, NULL);
87
	    }
88
	    else {
89
	            seahorse_agent_io_reply (rq, TRUE, pass);
90
	    }
85
            return;
91
            return;
86
        }
92
        }
87
    }
93
    }
Lines 89-94 seahorse_agent_actions_getpass (Seahorse Link Here
89
    /* A new queue item */
95
    /* A new queue item */
90
    pr = g_chunk_new (SeahorseAgentPassReq, g_memory);
96
    pr = g_chunk_new (SeahorseAgentPassReq, g_memory);
91
    memset (pr, 0, sizeof (*pr));
97
    memset (pr, 0, sizeof (*pr));
98
    pr->pass_as_data = pass_as_data;
92
    pr->id = id ? g_strdup (id) : NULL;
99
    pr->id = id ? g_strdup (id) : NULL;
93
    pr->errmsg = errmsg ? g_strdup (errmsg) : NULL;
100
    pr->errmsg = errmsg ? g_strdup (errmsg) : NULL;
94
    pr->prompt = g_strdup (prompt ? prompt : _("Passphrase:"));
101
    pr->prompt = g_strdup (prompt ? prompt : _("Passphrase:"));
Lines 133-139 seahorse_agent_actions_doneauth (Seahors Link Here
133
         * exists also locks it into the cache.
140
         * exists also locks it into the cache.
134
         */
141
         */
135
        g_assert (pr->id);
142
        g_assert (pr->id);
136
        pass = seahorse_agent_cache_get (pr->id);
143
        pass = seahorse_agent_cache_get (pr->pass_as_data, pr->id);
137
        g_assert (pass != NULL);
144
        g_assert (pass != NULL);
138
    }
145
    }
139
146
Lines 146-153 seahorse_agent_actions_donepass (Seahors Link Here
146
{
153
{
147
    if (pass == NULL)
154
    if (pass == NULL)
148
        seahorse_agent_io_reply (pr->request, FALSE, "111 cancelled");
155
        seahorse_agent_io_reply (pr->request, FALSE, "111 cancelled");
149
    else
156
    else {
150
        seahorse_agent_io_reply (pr->request, TRUE, pass);
157
    	if (pr->pass_as_data) {
158
	        seahorse_agent_io_data (pr->request, pass);
159
	        seahorse_agent_io_reply (pr->request, TRUE, NULL);
160
	}
161
	else {
162
	        seahorse_agent_io_reply (pr->request, TRUE, pass);
163
	}
164
    }
151
165
152
    free_passreq (pr);
166
    free_passreq (pr);
153
    seahorse_agent_actions_nextgui ();
167
    seahorse_agent_actions_nextgui ();
(-)seahorse-0.8.2.org/agent/seahorse-agent-cache.c (-19 / +24 lines)
Lines 46-51 Link Here
46
typedef struct sa_cache_t {
46
typedef struct sa_cache_t {
47
    gchar *id;                  /* The password id */
47
    gchar *id;                  /* The password id */
48
    gchar *pass;                /* The password itself (pointer to secure mem) */
48
    gchar *pass;                /* The password itself (pointer to secure mem) */
49
    gchar *enc_pass;            /* The password itself (pointer to secure mem) */
49
    gchar *desc;                /* A description of the key (parsed below) */
50
    gchar *desc;                /* A description of the key (parsed below) */
50
    gboolean locked;            /* Whether this entry is locked in the cache */
51
    gboolean locked;            /* Whether this entry is locked in the cache */
51
    time_t stamp;               /* The time which this password was last accessed */
52
    time_t stamp;               /* The time which this password was last accessed */
Lines 129-134 destroy_cache_item (gpointer data) Link Here
129
        if (it->pass)
130
        if (it->pass)
130
            secmem_free (it->pass);
131
            secmem_free (it->pass);
131
132
133
        if (it->enc_pass)
134
            secmem_free (it->enc_pass);
135
132
        g_chunk_free (it, g_memory);
136
        g_chunk_free (it, g_memory);
133
    }
137
    }
134
}
138
}
Lines 206-212 seahorse_agent_cache_uninit () Link Here
206
210
207
/* Retrieve a password from the cache */
211
/* Retrieve a password from the cache */
208
const gchar *
212
const gchar *
209
seahorse_agent_cache_get (const gchar *id)
213
seahorse_agent_cache_get (gboolean pass_as_data, const gchar *id)
210
{
214
{
211
    sa_cache_t *it;
215
    sa_cache_t *it;
212
216
Lines 227-233 seahorse_agent_cache_get (const gchar *i Link Here
227
        if (it->locked)
231
        if (it->locked)
228
            it->locked = FALSE;
232
            it->locked = FALSE;
229
            
233
            
230
        return it->pass;
234
	if (pass_as_data) {
235
		return it->pass;
236
	}
237
	else {
238
        	return it->enc_pass;
239
	}
231
    }
240
    }
232
241
233
    return NULL;
242
    return NULL;
Lines 357-384 seahorse_agent_cache_set (const gchar *i Link Here
357
366
358
    len = strlen (pass);
367
    len = strlen (pass);
359
368
360
    if (encode) {
369
    c = sizeof (gchar) * ((len * 2) + 1);
361
        c = sizeof (gchar *) * ((len * 2) + 1);
370
    it->enc_pass = (gchar *) secmem_malloc (c);
362
        it->pass = (gchar *) secmem_malloc (c);
371
    if (!it->enc_pass) {
363
        if (!it->pass) {
372
        g_critical ("out of secure memory");
364
            g_critical ("out of secure memory");
373
        return;
365
            return;
366
        }
367
368
        memset (it->pass, 0, c);
369
        encode_password (it->pass, pass);
370
    }
374
    }
371
375
372
    else {
376
    memset (it->enc_pass, 0, c);
373
        it->pass = (gchar *) secmem_malloc (sizeof (gchar) * (len + 1));
377
    encode_password (it->enc_pass, pass);
374
        if (!it->pass) {
375
            g_critical ("out of secure memory");
376
            return;
377
        }
378
378
379
        strcpy (it->pass, pass);
379
    it->pass = (gchar *) secmem_malloc (sizeof (gchar) * (len + 1));
380
    if (!it->pass) {
381
        g_critical ("out of secure memory");
382
        return;
380
    }
383
    }
381
384
385
    strcpy (it->pass, pass);
386
382
    /* If not caching set to the epoch which should always expire */
387
    /* If not caching set to the epoch which should always expire */
383
    it->stamp = cache ? time (NULL) : 0;
388
    it->stamp = cache ? time (NULL) : 0;
384
    it->locked = lock ? TRUE : FALSE;
389
    it->locked = lock ? TRUE : FALSE;
(-)seahorse-0.8.2.org/agent/seahorse-agent.h (-3 / +5 lines)
Lines 50-55 int seahorse_agent_io_socket (const char Link Here
50
int seahorse_agent_io_init ();
50
int seahorse_agent_io_init ();
51
void seahorse_agent_io_uninit ();
51
void seahorse_agent_io_uninit ();
52
void seahorse_agent_io_reply (SeahorseAgentConn *rq, gboolean ok, const gchar *response);
52
void seahorse_agent_io_reply (SeahorseAgentConn *rq, gboolean ok, const gchar *response);
53
void seahorse_agent_io_data (SeahorseAgentConn *cn, const gchar *data);
53
54
54
/* -----------------------------------------------------------------------------
55
/* -----------------------------------------------------------------------------
55
 * seahorse-agent-actions.c
56
 * seahorse-agent-actions.c
Lines 57-62 void seahorse_agent_io_reply (SeahorseAg Link Here
57
58
58
59
59
typedef struct _SeahorseAgentPassReq {
60
typedef struct _SeahorseAgentPassReq {
61
    gboolean pass_as_data;
60
    const gchar *id;
62
    const gchar *id;
61
    const gchar *errmsg;
63
    const gchar *errmsg;
62
    const gchar *prompt;
64
    const gchar *prompt;
Lines 66-73 typedef struct _SeahorseAgentPassReq { Link Here
66
68
67
void seahorse_agent_actions_init ();
69
void seahorse_agent_actions_init ();
68
void seahorse_agent_actions_uninit ();
70
void seahorse_agent_actions_uninit ();
69
void seahorse_agent_actions_getpass (SeahorseAgentConn *rq, gchar *id, gchar *errmsg,
71
void seahorse_agent_actions_getpass (SeahorseAgentConn *rq, gboolean pass_as_data, gchar *id,
70
                                     gchar *prompt, gchar *desc);
72
                                     gchar *errmsg, gchar *prompt, gchar *desc);
71
void seahorse_agent_actions_clrpass (SeahorseAgentConn *rq, gchar *id);
73
void seahorse_agent_actions_clrpass (SeahorseAgentConn *rq, gchar *id);
72
void seahorse_agent_actions_doneauth (SeahorseAgentPassReq *pr, gboolean authorized);
74
void seahorse_agent_actions_doneauth (SeahorseAgentPassReq *pr, gboolean authorized);
73
void seahorse_agent_actions_donepass (SeahorseAgentPassReq *pr, const gchar *pass);
75
void seahorse_agent_actions_donepass (SeahorseAgentPassReq *pr, const gchar *pass);
Lines 79-85 void seahorse_agent_actions_nextgui (); Link Here
79
81
80
void seahorse_agent_cache_init ();
82
void seahorse_agent_cache_init ();
81
void seahorse_agent_cache_uninit ();
83
void seahorse_agent_cache_uninit ();
82
const gchar *seahorse_agent_cache_get (const gchar *id);
84
const gchar *seahorse_agent_cache_get (gboolean pass_as_data, const gchar *id);
83
void seahorse_agent_cache_set (const gchar *id, const gchar *pass,
85
void seahorse_agent_cache_set (const gchar *id, const gchar *pass,
84
                               gboolean encode, gboolean lock);
86
                               gboolean encode, gboolean lock);
85
gboolean seahorse_agent_cache_has (const gchar *id, gboolean lock);
87
gboolean seahorse_agent_cache_has (const gchar *id, gboolean lock);
(-)seahorse-0.8.2.org/agent/seahorse-agent-io.c (-2 / +34 lines)
Lines 99-104 struct _SeahorseAgentConn { Link Here
99
/* Responses */
99
/* Responses */
100
#define ASS_OK      "OK "
100
#define ASS_OK      "OK "
101
#define ASS_ERR     "ERR "
101
#define ASS_ERR     "ERR "
102
#define ASS_DATA    "D "
102
#define NL          "\n"
103
#define NL          "\n"
103
104
104
/* -----------------------------------------------------------------------------
105
/* -----------------------------------------------------------------------------
Lines 327-336 process_line (SeahorseAgentConn *cn, gch Link Here
327
    }
328
    }
328
329
329
    else if (strcasecmp (string, ASS_GETPASS) == 0) {
330
    else if (strcasecmp (string, ASS_GETPASS) == 0) {
331
    	gchar *tmp;
330
        gchar *id;
332
        gchar *id;
331
        gchar *errmsg;
333
        gchar *errmsg;
332
        gchar *prompt;
334
        gchar *prompt;
333
        gchar *description;
335
        gchar *description;
336
	gboolean pass_as_data = FALSE;
334
337
335
        /* We don't answer this unless it's from the right terminal */
338
        /* We don't answer this unless it's from the right terminal */
336
        if (!cn->terminal_ok) {
339
        if (!cn->terminal_ok) {
Lines 339-345 process_line (SeahorseAgentConn *cn, gch Link Here
339
            return;
342
            return;
340
        }
343
        }
341
                
344
                
342
        split_arguments (args, &id, &errmsg, &prompt, &description, NULL);
345
	if (strstr (args, "--data") != NULL) {
346
		pass_as_data = TRUE;
347
	        split_arguments (args, &tmp, &tmp, &id, &errmsg, &prompt, &description, NULL);
348
	}
349
	else {
350
	        split_arguments (args, &id, &errmsg, &prompt, &description, NULL);
351
	}
343
352
344
        if (!id || !errmsg || !prompt || !description) {
353
        if (!id || !errmsg || !prompt || !description) {
345
            seahorse_agent_io_reply (cn, FALSE, "105 parameter error");
354
            seahorse_agent_io_reply (cn, FALSE, "105 parameter error");
Lines 356-362 process_line (SeahorseAgentConn *cn, gch Link Here
356
        if (is_null_argument (description))
365
        if (is_null_argument (description))
357
            description = NULL;
366
            description = NULL;
358
367
359
        seahorse_agent_actions_getpass (cn, id, errmsg, prompt, description);
368
        seahorse_agent_actions_getpass (cn, pass_as_data, id, errmsg, prompt, description);
360
    }
369
    }
361
370
362
    else if (strcasecmp (string, ASS_CLRPASS) == 0) {
371
    else if (strcasecmp (string, ASS_CLRPASS) == 0) {
Lines 512-517 seahorse_agent_io_reply (SeahorseAgentCo Link Here
512
    return;
521
    return;
513
}
522
}
514
523
524
void
525
seahorse_agent_io_data (SeahorseAgentConn *cn, const gchar *data)
526
{
527
    int fd;
528
529
    /* The connection could have closed in the meantime */
530
    if (!is_valid_conn (cn))
531
        return;
532
533
    DEBUG_AGENTIO (("[agent-io] send data:\n%s%s\n", ASS_DATA, data));
534
535
    fd = g_io_channel_unix_get_fd (cn->iochannel);
536
537
    if (write_raw_data (fd, ASS_DATA, KL (ASS_DATA)) == -1 ||
538
        write_raw_data (fd, data, -1) == -1 ||
539
	write_raw_data (fd, NL, KL (NL)) == -1) {
540
        /* error message already printed */
541
        disconnect (cn);
542
    }
543
544
    return;
545
}
546
515
/* Callback for new incoming connections */
547
/* Callback for new incoming connections */
516
static gboolean
548
static gboolean
517
connect_handler (GIOChannel *source, GIOCondition cond, gpointer data)
549
connect_handler (GIOChannel *source, GIOCondition cond, gpointer data)
(-)seahorse-0.8.2.org/agent/seahorse-agent-prompt.c (-1 / +1 lines)
Lines 121-127 prompt_done_dialog (SeahorseAgentPassReq Link Here
121
121
122
    if (ok) {
122
    if (ok) {
123
      
123
      
124
        pass = seahorse_agent_cache_get (pr->id);
124
        pass = seahorse_agent_cache_get (pr->pass_as_data, pr->id);
125
        g_assert (pass);
125
        g_assert (pass);
126
    }
126
    }
127
127
(-)seahorse-0.8.2.org/configure (-15 / +4 lines)
Lines 19569-19576 else Link Here
19569
fi;
19569
fi;
19570
19570
19571
if test	"$DO_CHECK" = "yes"; then
19571
if test	"$DO_CHECK" = "yes"; then
19572
  major_versions="1"
19572
  accept_versions="1.2 1.4 2.0"
19573
  minor_versions="2 4"
19574
  # Extract the first word of "gpg", so it can be a program name with args.
19573
  # Extract the first word of "gpg", so it can be a program name with args.
19575
set dummy gpg; ac_word=$2
19574
set dummy gpg; ac_word=$2
19576
echo "$as_me:$LINENO: checking for $ac_word" >&5
19575
echo "$as_me:$LINENO: checking for $ac_word" >&5
Lines 19623-19643 echo $ECHO_N "checking for appropriate G Link Here
19623
	micro=`echo $gnupg_version | \
19622
	micro=`echo $gnupg_version | \
19624
		sed 's/^gpg (GnuPG) \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\3/'`
19623
		sed 's/^gpg (GnuPG) \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\3/'`
19625
19624
19626
    for ver in $major_versions; do
19625
	for ver in $accept_versions; do
19627
      if test "$ver" = "$major"; then
19626
		if test "$ver" = "$major.$minor"; then
19628
19629
        # Check the minor version
19630
        for ver2 in $minor_versions; do
19631
          if test "$ver2" = "$minor"; then
19632
19633
            ok="yes"
19627
            ok="yes"
19634
            break
19628
            break
19635
19629
		fi
19636
          fi
19637
        done
19638
        break
19639
19640
      fi
19641
    done
19630
    done
19642
19631
19643
  fi
19632
  fi
(-)seahorse-0.8.2.org/configure.in (-16 / +5 lines)
Lines 59-66 AC_ARG_ENABLE(gpg-check, Link Here
59
	DO_CHECK=$enableval, DO_CHECK=yes)
59
	DO_CHECK=$enableval, DO_CHECK=yes)
60
	
60
	
61
if test	"$DO_CHECK" = "yes"; then
61
if test	"$DO_CHECK" = "yes"; then
62
  major_versions="1"
62
  accept_versions="1.2 1.4 2.0"
63
  minor_versions="2 4"
64
  AC_PATH_PROG(GNUPG, gpg, no)
63
  AC_PATH_PROG(GNUPG, gpg, no)
65
  ok="no"
64
  ok="no"
66
  if test "$GNUPG" != "no"; then
65
  if test "$GNUPG" != "no"; then
Lines 72-93 if test "$DO_CHECK" = "yes"; then Link Here
72
		sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
71
		sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
73
	micro=`echo $gnupg_version | \
72
	micro=`echo $gnupg_version | \
74
		sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
73
		sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
75
    
74
  
76
    for ver in $major_versions; do
75
	for ver in $accept_versions; do
77
      if test "$ver" = "$major"; then
76
		if test "$ver" = "$major.$minor"; then
78
            
79
        # Check the minor version 
80
        for ver2 in $minor_versions; do
81
          if test "$ver2" = "$minor"; then
82
                    
83
            ok="yes"
77
            ok="yes"
84
            break
78
            break
85
                    
79
		fi
86
          fi
87
        done
88
        break
89
            
90
      fi
91
    done
80
    done
92
    
81
    
93
  fi
82
  fi
(-)seahorse-0.8.2.org/libseahorse/seahorse-gpg-options.c (-2 / +3 lines)
Lines 32-38 Link Here
32
#include "seahorse-gpg-options.h"
32
#include "seahorse-gpg-options.h"
33
33
34
#define  GPG_CONF_HEADER    "# FILE CREATED BY SEAHORSE\n\n"
34
#define  GPG_CONF_HEADER    "# FILE CREATED BY SEAHORSE\n\n"
35
#define  GPG_VERSION_PREFIX   "1."
36
35
37
static gchar gpg_homedir[MAXPATHLEN];
36
static gchar gpg_homedir[MAXPATHLEN];
38
static gboolean gpg_options_inited = FALSE;
37
static gboolean gpg_options_inited = FALSE;
Lines 271-279 gpg_options_init (GError **err) Link Here
271
        /* 
270
        /* 
272
         * Make sure it's the right version for us to be messing 
271
         * Make sure it's the right version for us to be messing 
273
         * around with the configuration file.
272
         * around with the configuration file.
273
		 * Both 1.* and 2.* are suitable.
274
         */
274
         */
275
        g_return_val_if_fail (engine && engine->version && engine->file_name &&
275
        g_return_val_if_fail (engine && engine->version && engine->file_name &&
276
                              g_str_has_prefix (engine->version, GPG_VERSION_PREFIX),
276
                              (g_str_has_prefix (engine->version, "1.") ||
277
                               g_str_has_prefix (engine->version, "2.")),
277
                              (seahorse_util_gpgme_to_error
278
                              (seahorse_util_gpgme_to_error
278
                               (GPG_E (GPG_ERR_INV_ENGINE), err), FALSE));
279
                               (GPG_E (GPG_ERR_INV_ENGINE), err), FALSE));
279
280

Return to bug 164523