~mrooney/ecryptfs/nautilus-integration

« back to all changes in this revision

Viewing changes to src/libecryptfs/main.c

  • Committer: Dustin Kirkland
  • Date: 2009-02-03 08:18:53 UTC
  • Revision ID: git-v1:b0090ac8d4f626339d7f8ca5681934d5e68dac3e
make most of the code compatible with -Werror

Thanks to Michal Hlavinka for the patch.  This has been on my
to-do list for a while now!

Patch retrieved from:
https://bugzilla.redhat.com/show_bug.cgi?id=479762

Signed-off-by: Dustin Kirkland <kirkland@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 * 02111-1307, USA.
20
20
 */
21
21
 
 
22
#include "config.h"
22
23
#include <errno.h>
23
24
#ifdef ENABLE_NSS
24
 
#include <nss/pk11func.h>
25
 
#include <nss/secmod.h>
26
 
#include <nss/secmodt.h>
 
25
#include <nss.h>
 
26
#include <pk11func.h>
27
27
#else
28
28
#include <gcrypt.h>
29
29
#endif /* #ifdef ENABLE_NSS */
42
42
#include <sys/ipc.h>
43
43
#include <sys/shm.h>
44
44
#include <sys/sem.h>
45
 
#include "config.h"
46
45
#include "../include/ecryptfs.h"
47
46
 
48
47
int ecryptfs_verbosity = 0;
88
87
#endif /* #ifdef ENABLE_NSS */
89
88
 
90
89
#ifdef ENABLE_NSS
91
 
        NSS_NoDB_Init();
92
 
        err = PK11_HashBuf(algo, dst, src, src_size);
 
90
        NSS_NoDB_Init(NULL);
 
91
        err = PK11_HashBuf(algo, (unsigned char *)dst, (unsigned char *)src,
 
92
                           src_size);
93
93
        if (err == SECFailure) {
94
94
                syslog(LOG_ERR, "%s: PK11_HashBuf() error; SECFailure = [%d]; "
95
95
                       "PORT_GetError() = [%d]\n", __FUNCTION__, SECFailure,
186
186
        auth_tok->version = (((uint16_t)(major << 8) & 0xFF00)
187
187
                             | ((uint16_t)minor & 0x00FF));
188
188
        auth_tok->token_type = ECRYPTFS_PASSWORD;
189
 
        strncpy(auth_tok->token.password.signature, passphrase_sig,
 
189
        strncpy((char *)auth_tok->token.password.signature, passphrase_sig,
190
190
                ECRYPTFS_PASSWORD_SIG_SIZE);
191
191
        memcpy(auth_tok->token.password.salt, salt, ECRYPTFS_SALT_SIZE);
192
192
        memcpy(auth_tok->token.password.session_key_encryption_key,
257
257
        }
258
258
        if (key_data_len == 0) {
259
259
                if ((rc = (key_mod->ops->get_key_sig)(
260
 
                             sig,
 
260
                             (unsigned char *)sig,
261
261
                             auth_tok->token.private_key.data))) {
262
262
                        syslog(LOG_ERR, "Call into key module's get_key_sig "
263
263
                               "failed; rc = [%d]\n", rc);
276
276
                        goto out;
277
277
                }
278
278
                if ((rc = ecryptfs_generate_sig_from_key_data(
279
 
                             sig, key_data, key_data_len))) {
 
279
                             (unsigned char *)sig, key_data, key_data_len))) {
280
280
                        syslog(LOG_ERR, "Error attempting to generate "
281
281
                               "signature from key data; rc = [%d]\n", rc);
282
282
                        goto out;
283
283
                }
284
284
                if (sig[0] == '\0') {
285
285
                        if ((rc = (key_mod->ops->get_key_sig)(
286
 
                                     sig,
 
286
                                     (unsigned char *)sig,
287
287
                                     auth_tok->token.private_key.data))) {
288
288
                                syslog(LOG_ERR, "Call into key module's "
289
289
                                       "get_key_sig failed; rc = [%d]\n", rc);
309
309
        struct mntent mountent;
310
310
        char *fullpath_source = NULL;
311
311
        char *fullpath_target = NULL;
312
 
        int i;
313
312
        int rc;
314
313
 
315
314
        mountent.mnt_opts = NULL;
475
474
                        sleep(1);
476
475
                } else if (rc == -1) {
477
476
                        syslog(LOG_ERR, "Error locking semaphore; errno "
478
 
                               "string = [%m]\n", errno);
 
477
                               "string = [%m]\n");
479
478
                        goto out;
480
479
                } else
481
480
                        goto out;
524
523
                shm_virt = shmat((*shm_id), NULL, 0);
525
524
                if (shm_virt == (void *)-1) {
526
525
                        syslog(LOG_ERR, "Error attaching to newly allocated "
527
 
                               "shared memory; errno string = [%m]\n", errno);
 
526
                               "shared memory; errno string = [%m]\n");
528
527
                        rc = -EIO;
529
528
                        zombie_semaphore_unlock((*sem_id));
530
529
                        goto out;
539
538
        }
540
539
        if (rc == -1) {
541
540
                syslog(LOG_ERR, "Error attempting to get identifier for "
542
 
                       "shared memory with key [0x.8x]\n", ECRYPTFS_SHM_KEY);
 
541
                       "shared memory with key [0x%.8x]\n", ECRYPTFS_SHM_KEY);
543
542
                rc = -EIO;
544
543
                zombie_semaphore_unlock((*sem_id));
545
544
                goto out;
737
736
        shm_virt = shmat(shm_id, NULL, 0);
738
737
        if (shm_virt == (void *)-1) {
739
738
                syslog(LOG_ERR, "Error attaching to shared memory; error "
740
 
                       "string = [%m]\n", errno);
 
739
                       "string = [%m]\n");
741
740
                shm_virt = shmat(shm_id, NULL, 0);
742
741
                if (shm_virt == (void *)-1) {
743
742
                        syslog(LOG_ERR, "Error attaching to shared memory; error "
744
 
                               "string = [%m]\n", errno);
 
743
                               "string = [%m]\n");
745
744
                        rc = -EIO;
746
745
                        goto out;
747
746
                }
849
848
                if ((rc = kill(pid, SIGKILL))) {
850
849
                        syslog(LOG_ERR, "Error attempting to kill process "
851
850
                               "[%d]; rc = [%d]; errno string = [%m]\n", pid,
852
 
                               rc, errno);
 
851
                               rc);
853
852
                }
854
853
                if ((rc = remove_pid_for_this_sid(shm_id))) {
855
854
                        syslog(LOG_ERR, "Error attempting to remove pid/sid "