Line |
Branch |
Exec |
Source |
1 |
|
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ |
2 |
|
|
|
3 |
|
|
/* |
4 |
|
|
* Copyright (C) 2004 Red Hat, Inc. |
5 |
|
|
* |
6 |
|
|
* Nautilus is free software; you can redistribute it and/or |
7 |
|
|
* modify it under the terms of the GNU General Public License as |
8 |
|
|
* published by the Free Software Foundation; either version 2 of the |
9 |
|
|
* License, or (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* Nautilus is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
|
|
* General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 |
|
|
* |
20 |
|
|
* Authors: Alexander Larsson <alexl@redhat.com> |
21 |
|
|
* |
22 |
|
|
*/ |
23 |
|
|
|
24 |
|
|
#include "file-share-properties.h" |
25 |
|
|
|
26 |
|
|
#include <string.h> |
27 |
|
|
#include <stdio.h> |
28 |
|
|
|
29 |
|
|
#include <glib.h> |
30 |
|
|
|
31 |
|
|
|
32 |
|
|
#define REALM "Please log in as the user guest" |
33 |
|
|
#define USER "guest" |
34 |
|
|
|
35 |
|
|
void |
36 |
|
✗ |
file_share_write_out_password (const char *password) |
37 |
|
|
{ |
38 |
|
✗ |
g_autofree gchar *to_hash = NULL; |
39 |
|
✗ |
g_autofree gchar *ascii_digest = NULL; |
40 |
|
✗ |
g_autofree gchar *line = NULL; |
41 |
|
✗ |
g_autofree gchar *filename = NULL; |
42 |
|
|
FILE *file; |
43 |
|
|
|
44 |
|
✗ |
to_hash = g_strdup_printf ("%s:%s:%s", USER, REALM, password); |
45 |
|
✗ |
ascii_digest = g_compute_checksum_for_string (G_CHECKSUM_MD5, to_hash, strlen (to_hash)); |
46 |
|
✗ |
line = g_strdup_printf ("%s:%s:%s\n", USER, REALM, ascii_digest); |
47 |
|
|
|
48 |
|
✗ |
filename = g_build_filename (g_get_user_config_dir (), "user-share", "passwd", NULL); |
49 |
|
|
|
50 |
|
✗ |
file = fopen (filename, "w"); |
51 |
|
✗ |
if (file != NULL) { |
52 |
|
✗ |
fwrite (line, strlen (line), 1, file); |
53 |
|
✗ |
fclose (file); |
54 |
|
|
} |
55 |
|
✗ |
} |
56 |
|
|
|