summaryrefslogtreecommitdiffstats
path: root/src/slave/kprop.c
blob: f14f67bca3614f5d4efd8568fd027c2698d0cd64 (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/* slave/kprop.c */
/*
 * Copyright 1990,1991,2008 by the Massachusetts Institute of Technology.
 * All Rights Reserved.
 *
 * Export of this software from the United States of America may
 *   require a specific license from the United States Government.
 *   It is the responsibility of any person or organization contemplating
 *   export to obtain such a license before exporting.
 *
 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
 * distribute this software and its documentation for any purpose and
 * without fee is hereby granted, provided that the above copyright
 * notice appear in all copies and that both that copyright notice and
 * this permission notice appear in supporting documentation, and that
 * the name of M.I.T. not be used in advertising or publicity pertaining
 * to distribution of the software without specific, written prior
 * permission.  Furthermore if you modify this software you must label
 * your software as modified software and not distribute it in such a
 * fashion that it might be confused with the original M.I.T. software.
 * M.I.T. makes no representations about the suitability of
 * this software for any purpose.  It is provided "as is" without express
 * or implied warranty.
 */

#include <errno.h>
#include <stdio.h>
#include <ctype.h>
#include <sys/file.h>
#include <signal.h>
#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/param.h>
#include <netdb.h>
#include <fcntl.h>

#include "k5-int.h"
#include "com_err.h"
#include "kprop.h"

#ifndef GETSOCKNAME_ARG3_TYPE
#define GETSOCKNAME_ARG3_TYPE unsigned int
#endif

static char *kprop_version = KPROP_PROT_VERSION;

char    *progname = 0;
int     debug = 0;
char    *srvtab = 0;
char    *slave_host;
char    *realm = 0;
char    *file = KPROP_DEFAULT_FILE;

krb5_principal  my_principal;           /* The Kerberos principal we'll be */
/* running under, initialized in */
/* get_tickets() */
krb5_ccache     ccache;         /* Credentials cache which we'll be using */
krb5_creds      creds;
krb5_address    *sender_addr;
krb5_address    *receiver_addr;
const char      *port = KPROP_SERVICE;

void    PRS(int, char **);
void    get_tickets(krb5_context);
static void usage(void);
static void open_connection(krb5_context, char *, int *);
void    kerberos_authenticate(krb5_context, krb5_auth_context *,
                              int, krb5_principal, krb5_creds **);
int     open_database(krb5_context, char *, int *);
void    close_database(krb5_context, int);
void    xmit_database(krb5_context, krb5_auth_context, krb5_creds *,
                      int, int, int);
void    send_error(krb5_context, krb5_creds *, int, char *, krb5_error_code);
void    update_last_prop_file(char *, char *);

static void usage()
{
    fprintf(stderr, "\nUsage: %s [-r realm] [-f file] [-d] [-P port] [-s srvtab] slave_host\n\n",
            progname);
    exit(1);
}

int
main(argc, argv)
    int     argc;
    char    **argv;
{
    int     fd, database_fd, database_size;
    krb5_error_code retval;
    krb5_context context;
    krb5_creds *my_creds;
    krb5_auth_context auth_context;

    retval = krb5_init_context(&context);
    if (retval) {
        com_err(argv[0], retval, "while initializing krb5");
        exit(1);
    }
    PRS(argc, argv);
    get_tickets(context);

    database_fd = open_database(context, file, &database_size);
    open_connection(context, slave_host, &fd);
    kerberos_authenticate(context, &auth_context, fd, my_principal,
                          &my_creds);
    xmit_database(context, auth_context, my_creds, fd, database_fd,
                  database_size);
    update_last_prop_file(slave_host, file);
    printf("Database propagation to %s: SUCCEEDED\n", slave_host);
    krb5_free_cred_contents(context, my_creds);
    close_database(context, database_fd);
    exit(0);
}

void PRS(argc, argv)
    int     argc;
    char    **argv;
{
    register char   *word, ch;

    progname = *argv++;
    while (--argc && (word = *argv++)) {
        if (*word == '-') {
            word++;
            while (word && (ch = *word++)) {
                switch(ch){
                case 'r':
                    if (*word)
                        realm = word;
                    else
                        realm = *argv++;
                    if (!realm)
                        usage();
                    word = 0;
                    break;
                case 'f':
                    if (*word)
                        file = word;
                    else
                        file = *argv++;
                    if (!file)
                        usage();
                    word = 0;
                    break;
                case 'd':
                    debug++;
                    break;
                case 'P':
                    port = (*word != '\0') ? word : *argv++;
                    if (port == NULL)
                        usage();
                    word = 0;
                    break;
                case 's':
                    if (*word)
                        srvtab = word;
                    else
                        srvtab = *argv++;
                    if (!srvtab)
                        usage();
                    word = 0;
                    break;
                default:
                    usage();
                }

            }
        } else {
            if (slave_host)
                usage();
            else
                slave_host = word;
        }
    }
    if (!slave_host)
        usage();
}

void get_tickets(context)
    krb5_context context;
{
    char   buf[BUFSIZ], *def_realm;
    krb5_error_code retval;
    static char tkstring[] = "/tmp/kproptktXXXXXX";
    krb5_keytab keytab = NULL;

    /*
     * Figure out what tickets we'll be using to send stuff
     */
    retval = krb5_sname_to_principal(context, NULL, NULL,
                                     KRB5_NT_SRV_HST, &my_principal);
    if (retval) {
        com_err(progname, errno, "while setting client principal name");
        exit(1);
    }
    if (realm) {
        retval = krb5_set_principal_realm(context, my_principal, realm);
        if (retval) {
            com_err(progname, errno, "while setting client principal realm");
            exit(1);
        }
    } else if (krb5_is_referral_realm(krb5_princ_realm(context,
                                                       my_principal))) {
        /* We're going to use this as a client principal, so it can't have the
         * referral realm.  Use the default realm instead. */
        retval = krb5_get_default_realm(context, &def_realm);
        if (retval) {
            com_err(progname, errno, "while getting default realm");
            exit(1);
        }
        retval = krb5_set_principal_realm(context, my_principal, def_realm);
        if (retval) {
            com_err(progname, errno, "while setting client principal realm");
            exit(1);
        }
    }

#if 0
    krb5_princ_type(context, my_principal) = KRB5_NT_PRINCIPAL;
#endif

    /*
     * Initialize cache file which we're going to be using
     */
    (void) mktemp(tkstring);
    snprintf(buf, sizeof(buf), "FILE:%s", tkstring);

    retval = krb5_cc_resolve(context, buf, &ccache);
    if (retval) {
        com_err(progname, retval, "while opening credential cache %s",
                buf);
        exit(1);
    }

    retval = krb5_cc_initialize(context, ccache, my_principal);
    if (retval) {
        com_err (progname, retval, "when initializing cache %s",
                 buf);
        exit(1);
    }

    /*
     * Get the tickets we'll need.
     *
     * Construct the principal name for the slave host.
     */
    memset(&creds, 0, sizeof(creds));
    retval = krb5_sname_to_principal(context,
                                     slave_host, KPROP_SERVICE_NAME,
                                     KRB5_NT_SRV_HST, &creds.server);
    if (retval) {
        com_err(progname, errno, "while setting server principal name");
        (void) krb5_cc_destroy(context, ccache);
        exit(1);
    }
    if (realm) {
        retval = krb5_set_principal_realm(context, creds.server, realm);
        if (retval) {
            com_err(progname, errno,
                    "while setting server principal realm");
            exit(1);
        }
    }

    /*
     * Now fill in the client....
     */
    retval = krb5_copy_principal(context, my_principal, &creds.client);
    if (retval) {
        com_err(progname, retval, "While copying client principal");
        (void) krb5_cc_destroy(context, ccache);
        exit(1);
    }
    if (srvtab) {
        retval = krb5_kt_resolve(context, srvtab, &keytab);
        if (retval) {
            com_err(progname, retval, "while resolving keytab");
            (void) krb5_cc_destroy(context, ccache);
            exit(1);
        }
    }

    retval = krb5_get_in_tkt_with_keytab(context, 0, 0, NULL,
                                         NULL, keytab, ccache, &creds, 0);
    if (retval) {
        com_err(progname, retval, "while getting initial ticket\n");
        (void) krb5_cc_destroy(context, ccache);
        exit(1);
    }

    if (keytab)
        (void) krb5_kt_close(context, keytab);

    /*
     * Now destroy the cache right away --- the credentials we
     * need will be in my_creds.
     */
    retval = krb5_cc_destroy(context, ccache);
    if (retval) {
        com_err(progname, retval, "while destroying ticket cache");
        exit(1);
    }
}

static void
open_connection(krb5_context context, char *host, int *fd)
{
    int     s;
    krb5_error_code retval;
    GETSOCKNAME_ARG3_TYPE socket_length;
    struct addrinfo hints, *res, *answers;
    struct sockaddr *sa;
    struct sockaddr_storage my_sin;
    int error;

    memset(&hints, 0, sizeof(hints));
    hints.ai_family = PF_UNSPEC;
    hints.ai_socktype = SOCK_STREAM;
    error = getaddrinfo(host, port, &hints, &answers);
    if (error != 0) {
        com_err(progname, 0, "%s: %s", host, gai_strerror(error));
        exit(1);
    }

    s = -1;
    retval = EINVAL;
    for (res = answers; res != NULL; res = res->ai_next) {
        s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
        if (s < 0) {
            com_err(progname, errno, "while creating socket");
            exit(1);
        }

        if (connect(s, res->ai_addr, res->ai_addrlen) < 0) {
            retval = errno;
            close(s);
            s = -1;
            continue;
        }

        /* We successfully connect()ed */
        *fd = s;
        retval = sockaddr2krbaddr(context, res->ai_family, res->ai_addr,
                                  &receiver_addr);
        if (retval != 0) {
            com_err(progname, retval, "while converting server address");
            exit(1);
        }

        break;
    }

    freeaddrinfo(answers);

    if (s == -1) {
        com_err(progname, retval, "while connecting to server");
        exit(1);
    }

    /* Set sender_addr. */
    socket_length = sizeof(my_sin);
    if (getsockname(s, (struct sockaddr *)&my_sin, &socket_length) < 0) {
        com_err(progname, errno, "while getting local socket address");
        exit(1);
    }
    sa = (struct sockaddr *) &my_sin;
    if (sockaddr2krbaddr(context, sa->sa_family, sa, &sender_addr) != 0) {
        com_err(progname, errno, "while converting local address");
        exit(1);
    }
}


void kerberos_authenticate(context, auth_context, fd, me, new_creds)
    krb5_context context;
    krb5_auth_context *auth_context;
    int fd;
    krb5_principal me;
    krb5_creds ** new_creds;
{
    krb5_error_code retval;
    krb5_error      *error = NULL;
    krb5_ap_rep_enc_part    *rep_result;

    retval = krb5_auth_con_init(context, auth_context);
    if (retval)
        exit(1);

    krb5_auth_con_setflags(context, *auth_context,
                           KRB5_AUTH_CONTEXT_DO_SEQUENCE);

    retval = krb5_auth_con_setaddrs(context, *auth_context, sender_addr,
                                    receiver_addr);
    if (retval) {
        com_err(progname, retval, "in krb5_auth_con_setaddrs");
        exit(1);
    }

    retval = krb5_sendauth(context, auth_context, (void *)&fd,
                           kprop_version, me, creds.server,
                           AP_OPTS_MUTUAL_REQUIRED, NULL, &creds, NULL,
                           &error, &rep_result, new_creds);
    if (retval) {
        com_err(progname, retval, "while authenticating to server");
        if (error) {
            if (error->error == KRB_ERR_GENERIC) {
                if (error->text.data)
                    fprintf(stderr,
                            "Generic remote error: %s\n",
                            error->text.data);
            } else if (error->error) {
                com_err(progname,
                        (krb5_error_code) error->error + ERROR_TABLE_BASE_krb5,
                        "signalled from server");
                if (error->text.data)
                    fprintf(stderr,
                            "Error text from server: %s\n",
                            error->text.data);
            }
            krb5_free_error(context, error);
        }
        exit(1);
    }
    krb5_free_ap_rep_enc_part(context, rep_result);
}

char * dbpathname;
/*
 * Open the Kerberos database dump file.  Takes care of locking it
 * and making sure that the .ok file is more recent that the database
 * dump file itself.
 *
 * Returns the file descriptor of the database dump file.  Also fills
 * in the size of the database file.
 */
int
open_database(context, data_fn, size)
    krb5_context context;
    char *data_fn;
    int *size;
{
    int             fd;
    int             err;
    struct stat     stbuf, stbuf_ok;
    char            *data_ok_fn;
    static char ok[] = ".dump_ok";

    dbpathname = strdup(data_fn);
    if (!dbpathname) {
        com_err(progname, ENOMEM, "allocating database file name '%s'",
                data_fn);
        exit(1);
    }
    if ((fd = open(dbpathname, O_RDONLY)) < 0) {
        com_err(progname, errno, "while trying to open %s",
                dbpathname);
        exit(1);
    }

    err = krb5_lock_file(context, fd,
                         KRB5_LOCKMODE_SHARED|KRB5_LOCKMODE_DONTBLOCK);
    if (err == EAGAIN || err == EWOULDBLOCK || errno == EACCES) {
        com_err(progname, 0, "database locked");
        exit(1);
    } else if (err) {
        com_err(progname, err, "while trying to lock '%s'", dbpathname);
        exit(1);
    }
    if (fstat(fd, &stbuf)) {
        com_err(progname, errno, "while trying to stat %s",
                data_fn);
        exit(1);
    }
    if (asprintf(&data_ok_fn, "%s%s", data_fn, ok) < 0) {
        com_err(progname, ENOMEM, "while trying to malloc data_ok_fn");
        exit(1);
    }
    if (stat(data_ok_fn, &stbuf_ok)) {
        com_err(progname, errno, "while trying to stat %s",
                data_ok_fn);
        free(data_ok_fn);
        exit(1);
    }
    if (stbuf.st_mtime > stbuf_ok.st_mtime) {
        com_err(progname, 0, "'%s' more recent than '%s'.",
                data_fn, data_ok_fn);
        exit(1);
    }
    free(data_ok_fn);
    *size = stbuf.st_size;
    return(fd);
}

void
close_database(context, fd)
    krb5_context context;
    int fd;
{
    int err;
    err = krb5_lock_file(context, fd, KRB5_LOCKMODE_UNLOCK);
    if (err)
        com_err(progname, err, "while unlocking database '%s'", dbpathname);
    free(dbpathname);
    (void)close(fd);
    return;
}

/*
 * Now we send over the database.  We use the following protocol:
 * Send over a KRB_SAFE message with the size.  Then we send over the
 * database in blocks of KPROP_BLKSIZE, encrypted using KRB_PRIV.
 * Then we expect to see a KRB_SAFE message with the size sent back.
 *
 * At any point in the protocol, we may send a KRB_ERROR message; this
 * will abort the entire operation.
 */
void
xmit_database(context, auth_context, my_creds, fd, database_fd,
              in_database_size)
    krb5_context context;
    krb5_auth_context auth_context;
    krb5_creds *my_creds;
    int fd;
    int database_fd;
    int in_database_size;
{
    krb5_int32      sent_size, n;
    krb5_data       inbuf, outbuf;
    char            buf[KPROP_BUFSIZ];
    krb5_error_code retval;
    krb5_error      *error;
    /* These must be 4 bytes */
    krb5_ui_4       database_size = in_database_size;
    krb5_ui_4       send_size;

    /*
     * Send over the size
     */
    send_size = htonl(database_size);
    inbuf.data = (char *) &send_size;
    inbuf.length = sizeof(send_size); /* must be 4, really */
    /* KPROP_CKSUMTYPE */
    retval = krb5_mk_safe(context, auth_context, &inbuf,
                          &outbuf, NULL);
    if (retval) {
        com_err(progname, retval, "while encoding database size");
        send_error(context, my_creds, fd, "while encoding database size", retval);
        exit(1);
    }

    retval = krb5_write_message(context, (void *) &fd, &outbuf);
    if (retval) {
        krb5_free_data_contents(context, &outbuf);
        com_err(progname, retval, "while sending database size");
        exit(1);
    }
    krb5_free_data_contents(context, &outbuf);
    /*
     * Initialize the initial vector.
     */
    retval = krb5_auth_con_initivector(context, auth_context);
    if (retval) {
        send_error(context, my_creds, fd,
                   "failed while initializing i_vector", retval);
        com_err(progname, retval, "while allocating i_vector");
        exit(1);
    }

    /*
     * Send over the file, block by block....
     */
    inbuf.data = buf;
    sent_size = 0;
    while ((n = read(database_fd, buf, sizeof(buf)))) {
        inbuf.length = n;
        retval = krb5_mk_priv(context, auth_context, &inbuf,
                              &outbuf, NULL);
        if (retval) {
            snprintf(buf, sizeof(buf),
                     "while encoding database block starting at %d",
                     sent_size);
            com_err(progname, retval, "%s", buf);
            send_error(context, my_creds, fd, buf, retval);
            exit(1);
        }

        retval = krb5_write_message(context, (void *)&fd,&outbuf);
        if (retval) {
            krb5_free_data_contents(context, &outbuf);
            com_err(progname, retval,
                    "while sending database block starting at %d",
                    sent_size);
            exit(1);
        }
        krb5_free_data_contents(context, &outbuf);
        sent_size += n;
        if (debug)
            printf("%d bytes sent.\n", sent_size);
    }
    if (sent_size != database_size) {
        com_err(progname, 0, "Premature EOF found for database file!");
        send_error(context, my_creds, fd,"Premature EOF found for database file!",
                   KRB5KRB_ERR_GENERIC);
        exit(1);
    }

    /*
     * OK, we've sent the database; now let's wait for a success
     * indication from the remote end.
     */
    retval = krb5_read_message(context, (void *) &fd, &inbuf);
    if (retval) {
        com_err(progname, retval,
                "while reading response from server");
        exit(1);
    }
    /*
     * If we got an error response back from the server, display
     * the error message
     */
    if (krb5_is_krb_error(&inbuf)) {
        retval = krb5_rd_error(context, &inbuf, &error);
        if (retval) {
            com_err(progname, retval,
                    "while decoding error response from server");
            exit(1);
        }
        if (error->error == KRB_ERR_GENERIC) {
            if (error->text.data)
                fprintf(stderr,
                        "Generic remote error: %s\n",
                        error->text.data);
        } else if (error->error) {
            com_err(progname,
                    (krb5_error_code) error->error +
                    ERROR_TABLE_BASE_krb5,
                    "signalled from server");
            if (error->text.data)
                fprintf(stderr,
                        "Error text from server: %s\n",
                        error->text.data);
        }
        krb5_free_error(context, error);
        exit(1);
    }

    retval = krb5_rd_safe(context,auth_context,&inbuf,&outbuf,NULL);
    if (retval) {
        com_err(progname, retval,
                "while decoding final size packet from server");
        exit(1);
    }

    memcpy(&send_size, outbuf.data, sizeof(send_size));
    send_size = ntohl(send_size);
    if (send_size != database_size) {
        com_err(progname, 0,
                "Kpropd sent database size %d, expecting %d",
                send_size, database_size);
        exit(1);
    }
    free(outbuf.data);
    /* inbuf.data points to local storage */
}

void
send_error(context, my_creds, fd, err_text, err_code)
    krb5_context context;
    krb5_creds *my_creds;
    int fd;
    char        *err_text;
    krb5_error_code     err_code;
{
    krb5_error      error;
    const char      *text;
    krb5_data       outbuf;

    memset(&error, 0, sizeof(error));
    krb5_us_timeofday(context, &error.ctime, &error.cusec);
    error.server = my_creds->server;
    error.client = my_principal;
    error.error = err_code - ERROR_TABLE_BASE_krb5;
    if (error.error > 127)
        error.error = KRB_ERR_GENERIC;
    if (err_text)
        text = err_text;
    else
        text = error_message(err_code);
    error.text.length = strlen(text) + 1;
    error.text.data = strdup(text);
    if (error.text.data) {
        if (!krb5_mk_error(context, &error, &outbuf)) {
            (void) krb5_write_message(context, (void *)&fd,&outbuf);
            krb5_free_data_contents(context, &outbuf);
        }
        free(error.text.data);
    }
}

void update_last_prop_file(hostname, file_name)
    char *hostname;
    char *file_name;
{
    /* handle slave locking/failure stuff */
    char *file_last_prop;
    int fd;
    static char last_prop[]=".last_prop";

    if (asprintf(&file_last_prop, "%s.%s%s", file_name, hostname,
                 last_prop) < 0) {
        com_err(progname, ENOMEM,
                "while allocating filename for update_last_prop_file");
        return;
    }
    if ((fd = THREEPARAMOPEN(file_last_prop, O_WRONLY|O_CREAT|O_TRUNC, 0600)) < 0) {
        com_err(progname, errno,
                "while creating 'last_prop' file, '%s'",
                file_last_prop);
        free(file_last_prop);
        return;
    }
    write(fd, "", 1);
    free(file_last_prop);
    close(fd);
    return;
}