]> arthur.barton.de Git - netatalk.git/blob - etc/afpd/status.c
Remove all Appletalk stuff
[netatalk.git] / etc / afpd / status.c
1 /*
2  * Copyright (c) 1990,1993 Regents of The University of Michigan.
3  * All Rights Reserved.  See COPYRIGHT.
4  */
5
6 #ifdef HAVE_CONFIG_H
7 #include "config.h"
8 #endif /* HAVE_CONFIG_H */
9
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <unistd.h>
13 #include <ctype.h>
14 #include <string.h>
15 #include <time.h>
16 #include <sys/types.h>
17 #include <sys/stat.h>
18 #include <fcntl.h>
19 #include <sys/socket.h>
20 #include <atalk/logger.h>
21
22 #if 0
23 #ifdef BSD4_4
24 #include <sys/param.h>
25 #ifndef HAVE_GETHOSTID
26 #include <sys/sysctl.h>
27 #endif /* HAVE_GETHOSTID */
28 #endif /* BSD4_4 */
29 #endif
30
31 #include <arpa/inet.h>
32
33 #include <atalk/dsi.h>
34 #include <atalk/unicode.h>
35 #include <atalk/util.h>
36
37 #include "globals.h"  /* includes <netdb.h> */
38 #include "status.h"
39 #include "afp_config.h"
40 #include "icon.h"
41
42 static   size_t maxstatuslen = 0;
43
44 static void status_flags(char *data, const int notif, const int ipok,
45                          const unsigned char passwdbits, const int dirsrvcs _U_, int flags)
46 {
47     u_int16_t           status;
48
49     status = AFPSRVRINFO_COPY;
50     if (passwdbits & PASSWD_SET) /* some uams may not allow this. */
51         status |= AFPSRVRINFO_PASSWD;
52     if (passwdbits & PASSWD_NOSAVE)
53         status |= AFPSRVRINFO_NOSAVEPASSWD;
54     status |= AFPSRVRINFO_SRVSIGNATURE;
55     /* only advertise tcp/ip if we have a valid address */
56     if (ipok)
57         status |= AFPSRVRINFO_TCPIP;
58     status |= AFPSRVRINFO_SRVMSGS;
59     /* Allow the user to decide if we should support server notifications.
60      * With this turned off, the clients will poll for directory changes every
61      * 10 seconds.  This might be too costly to network resources, so make
62      * this an optional thing.  Default will be to _not_ support server
63      * notifications. */
64     if (notif) {
65         status |= AFPSRVRINFO_SRVNOTIFY;
66     }
67     status |= AFPSRVRINFO_FASTBOZO;
68     status |= AFPSRVRINFO_SRVRDIR; /* AFP 3.1 specs says we need to specify this, but may set the count to 0 */
69     /* We don't set the UTF8 name flag here, we don't know whether we have enough space ... */
70
71     if (flags & OPTION_UUID)    /* 05122008 FIXME: can we set AFPSRVRINFO_UUID here ? see AFPSRVRINFO_SRVRDIR*/
72         status |= AFPSRVRINFO_UUID;
73
74     status = htons(status);
75     memcpy(data + AFPSTATUS_FLAGOFF, &status, sizeof(status));
76 }
77
78 static int status_server(char *data, const char *server, const struct afp_options *options)
79 {
80     char                *start = data;
81     char                *Obj, *Type, *Zone;
82     char                buf[32];
83     u_int16_t           status;
84     size_t              len;
85
86     /* make room for all offsets before server name */
87     data += AFPSTATUS_PRELEN;
88
89     /* extract the obj part of the server */
90     Obj = (char *) server;
91     if ((size_t)-1 == (len = convert_string( 
92                            options->unixcharset, options->maccharset, 
93                            Obj, -1, buf, sizeof(buf))) ) {
94         len = MIN(strlen(Obj), 31);
95         *data++ = len;
96         memcpy( data, Obj, len );
97         LOG ( log_error, logtype_afpd, "Could not set servername, using fallback");
98     } else {
99         *data++ = len;
100         memcpy( data, buf, len );
101     }
102     if ((len + 1) & 1) /* pad server name and length byte to even boundary */
103         len++;
104     data += len;
105
106     /* make room for signature and net address offset. save location of
107      * signature offset. we're also making room for directory names offset
108      * and the utf-8 server name offset.
109      *
110      * NOTE: technically, we don't need to reserve space for the
111      * signature and net address offsets if they're not going to be
112      * used. as there are no offsets after them, it doesn't hurt to
113      * have them specified though. so, we just do that to simplify
114      * things.  
115      *
116      * NOTE2: AFP3.1 Documentation states that the directory names offset
117      * is a required feature, even though it can be set to zero.
118      */
119     len = data - start;
120     status = htons(len + AFPSTATUS_POSTLEN);
121     memcpy(start + AFPSTATUS_MACHOFF, &status, sizeof(status));
122     return len; /* return the offset to beginning of signature offset */
123 }
124
125 static void status_machine(char *data)
126 {
127     char                *start = data;
128     u_int16_t           status;
129     int                 len;
130 #ifdef AFS
131     const char          *machine = "afs";
132 #else /* !AFS */
133     const char          *machine = "Netatalk %s";
134 #endif /* AFS */
135     char buf[64];
136
137     memcpy(&status, start + AFPSTATUS_MACHOFF, sizeof(status));
138     data += ntohs( status );
139
140     //    len = strlen( machine );
141     len = snprintf(buf, 64, machine, VERSION);
142     *data++ = len;
143     memcpy( data, buf, len );
144     data += len;
145
146     status = htons(data - start);
147     memcpy(start + AFPSTATUS_VERSOFF, &status, sizeof(status));
148 }
149
150 /* server signature is a 16-byte quantity */
151 static u_int16_t status_signature(char *data, int *servoffset,
152                                   const struct afp_options *options)
153 {
154     char                 *status;
155     u_int16_t            offset, sigoff;
156
157     status = data;
158
159     /* get server signature offset */
160     memcpy(&offset, data + *servoffset, sizeof(offset));
161     sigoff = offset = ntohs(offset);
162
163     /* jump to server signature offset */
164     data += offset;
165
166     memset(data, 0, 16);
167     memcpy(data, options->signature, 16);
168     data += 16;
169
170     /* calculate net address offset */
171     *servoffset += sizeof(offset);
172     offset = htons(data - status);
173     memcpy(status + *servoffset, &offset, sizeof(offset));
174     return sigoff;
175 }
176
177 static size_t status_netaddress(char *data, int *servoffset,
178                              const DSI *dsi,
179                              const struct afp_options *options)
180 {
181     char               *begin;
182     u_int16_t          offset;
183     size_t             addresses_len = 0;
184
185     begin = data;
186
187     /* get net address offset */
188     memcpy(&offset, data + *servoffset, sizeof(offset));
189     data += ntohs(offset);
190
191     /* format:
192        Address count (byte) 
193        len (byte = sizeof(length + address type + address) 
194        address type (byte, ip address = 0x01, ip + port = 0x02,
195                            ddp address = 0x03, fqdn = 0x04) 
196        address (up to 254 bytes, ip = 4, ip + port = 6, ddp = 4)
197        */
198
199     /* number of addresses. this currently screws up if we have a dsi
200        connection, but we don't have the ip address. to get around this,
201        we turn off the status flag for tcp/ip. */
202     *data++ = ((options->fqdn && dsi)? 1 : 0) + (dsi ? 1 : 0) +
203               (((options->flags & OPTION_ANNOUNCESSH) && options->fqdn && dsi)? 1 : 0);
204
205     /* ip address */
206     if (dsi) {
207         if (dsi->server.ss_family == AF_INET) { /* IPv4 */
208             const struct sockaddr_in *inaddr = (struct sockaddr_in *)&dsi->server;
209             if (inaddr->sin_port == htons(DSI_AFPOVERTCP_PORT)) {
210                 *data++ = 6; /* length */
211                 *data++ = 0x01; /* basic ip address */
212                 memcpy(data, &inaddr->sin_addr.s_addr,
213                        sizeof(inaddr->sin_addr.s_addr));
214                 data += sizeof(inaddr->sin_addr.s_addr);
215                 addresses_len += 7;
216             } else {
217                 /* ip address + port */
218                 *data++ = 8;
219                 *data++ = 0x02; /* ip address with port */
220                 memcpy(data, &inaddr->sin_addr.s_addr,
221                        sizeof(inaddr->sin_addr.s_addr));
222                 data += sizeof(inaddr->sin_addr.s_addr);
223                 memcpy(data, &inaddr->sin_port, sizeof(inaddr->sin_port));
224                 data += sizeof(inaddr->sin_port);
225                 addresses_len += 9;
226             }
227         } else { /* IPv6 */
228             const struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)&dsi->server;
229             if (sa6->sin6_port == htons(DSI_AFPOVERTCP_PORT)) {
230                 *data++ = 18; /* length */
231                 *data++ = 6; /* type */
232                 memcpy(data, &sa6->sin6_addr.s6_addr, sizeof(sa6->sin6_addr.s6_addr));
233                 data += sizeof(sa6->sin6_addr.s6_addr);
234                 addresses_len += 19;
235             } else {
236                 /* ip address + port */
237                 *data++ = 20; /* length */
238                 *data++ = 7; /* type*/
239                 memcpy(data, &sa6->sin6_addr.s6_addr, sizeof(sa6->sin6_addr.s6_addr));
240                 data += sizeof(sa6->sin6_addr.s6_addr);
241                 memcpy(data, &sa6->sin6_port, sizeof(sa6->sin6_port));
242                 data += sizeof(sa6->sin6_port);
243                 addresses_len += 21;
244             }
245
246         }
247     }
248
249     /* handle DNS names */
250     if (options->fqdn && dsi) {
251         size_t len = strlen(options->fqdn);
252         if ( len + 2 + addresses_len < maxstatuslen - offset) {
253             *data++ = len +2;
254             *data++ = 0x04;
255             memcpy(data, options->fqdn, len);
256             data += len;
257             addresses_len += len+2;
258         }
259
260         /* Annouce support for SSH tunneled AFP session, 
261          * this feature is available since 10.3.2.
262          * According to the specs (AFP 3.1 p.225) this should
263          * be an IP+Port style value, but it only works with 
264          * a FQDN. OSX Server uses FQDN as well.
265          */
266         if ( len + 2 + addresses_len < maxstatuslen - offset) {
267             if (options->flags & OPTION_ANNOUNCESSH) {
268                 *data++ = len +2;
269                 *data++ = 0x05;
270                 memcpy(data, options->fqdn, len);
271                 data += len;
272             }
273         }
274     }
275
276     /* calculate/store Directory Services Names offset */
277     offset = htons(data - begin); 
278     *servoffset += sizeof(offset);
279     memcpy(begin + *servoffset, &offset, sizeof(offset));
280
281     /* return length of buffer */
282     return (data - begin);
283 }
284
285 static size_t status_directorynames(char *data, int *diroffset, 
286                                  const DSI *dsi _U_, 
287                                  const struct afp_options *options)
288 {
289     char *begin = data;
290     u_int16_t offset;
291     memcpy(&offset, data + *diroffset, sizeof(offset));
292     offset = ntohs(offset);
293     data += offset;
294
295     /* I can not find documentation of any other purpose for the
296      * DirectoryNames field.
297      */
298     /*
299      * Try to synthesize a principal:
300      * service '/' fqdn '@' realm
301      */
302     if (options->k5service && options->k5realm && options->fqdn) {
303         /* should k5princ be utf8 encoded? */
304         size_t len;
305         char *p = strchr( options->fqdn, ':' );
306         if (p) 
307             *p = '\0';
308         len = strlen( options->k5service ) 
309                         + strlen( options->fqdn )
310                         + strlen( options->k5realm );
311         len+=2; /* '/' and '@' */
312         if ( len > 255 || len+2 > maxstatuslen - offset) {
313             *data++ = 0;
314             LOG ( log_error, logtype_afpd, "status: could not set directory service list, no more room");
315         }        
316         else {
317             *data++ = 1; /* DirectoryNamesCount */
318             *data++ = len;
319             snprintf( data, len + 1, "%s/%s@%s", options->k5service,
320                                 options->fqdn, options->k5realm );
321             data += len;
322             if (p)
323                 *p = ':';
324        }
325     } else {
326         *data++ = 0;
327     }
328
329     /* Calculate and store offset for UTF8ServerName */
330     *diroffset += sizeof(u_int16_t);
331     offset = htons(data - begin);
332     memcpy(begin + *diroffset, &offset, sizeof(u_int16_t));
333
334     /* return length of buffer */
335     return (data - begin);
336 }
337
338 static size_t status_utf8servername(char *data, int *nameoffset,
339                                  const DSI *dsi _U_,
340                                  const struct afp_options *options)
341 {
342     char *Obj, *Type, *Zone;
343     u_int16_t namelen;
344     size_t len;
345     char *begin = data;
346     u_int16_t offset, status;
347
348     memcpy(&offset, data + *nameoffset, sizeof(offset));
349     offset = ntohs(offset);
350     data += offset;
351
352     /* FIXME:
353      * What is the valid character range for an nbpname?
354      *
355      * Apple's server likes to use the non-qualified hostname
356      * This obviously won't work very well if multiple servers are running
357      * on the box.
358      */
359
360     /* extract the obj part of the server */
361     Obj = (char *) (options->server ? options->server : options->hostname);
362     if ((size_t) -1 == (len = convert_string (
363                             options->unixcharset, CH_UTF8_MAC, 
364                             Obj, -1, data+sizeof(namelen), maxstatuslen-offset )) ) {
365         LOG ( log_error, logtype_afpd, "Could not set utf8 servername");
366
367         /* set offset to 0 */
368         memset(begin + *nameoffset, 0, sizeof(offset));
369         data = begin + offset;
370     } else {
371         namelen = htons(len);
372         memcpy( data, &namelen, sizeof(namelen));
373         data += sizeof(namelen);
374         data += len;
375         offset = htons(offset);
376         memcpy(begin + *nameoffset, &offset, sizeof(u_int16_t));
377         
378         /* Now set the flag ... */
379         memcpy(&status, begin + AFPSTATUS_FLAGOFF, sizeof(status));
380         status = ntohs(status);
381         status |= AFPSRVRINFO_SRVUTF8;
382         status = htons(status);
383         memcpy(begin + AFPSTATUS_FLAGOFF, &status, sizeof(status));
384     }
385
386     /* return length of buffer */
387     return (data - begin);
388
389 }
390
391 /* returns actual offset to signature */
392 static void status_icon(char *data, const unsigned char *icondata,
393                         const int iconlen, const int sigoffset)
394 {
395     char                *start = data;
396     char                *sigdata = data + sigoffset;
397     u_int16_t           ret, status;
398
399     memcpy(&status, start + AFPSTATUS_ICONOFF, sizeof(status));
400     if ( icondata == NULL ) {
401         ret = status;
402         memset(start + AFPSTATUS_ICONOFF, 0, sizeof(status));
403     } else {
404         data += ntohs( status );
405         memcpy( data, icondata, iconlen);
406         data += iconlen;
407         ret = htons(data - start);
408     }
409
410     /* put in signature offset */
411     if (sigoffset)
412         memcpy(sigdata, &ret, sizeof(ret));
413 }
414
415 /* ---------------------
416  */
417 void status_init(AFPConfig *dsiconfig,
418                  const struct afp_options *options)
419 {
420     DSI *dsi;
421     char *status = NULL;
422     size_t statuslen;
423     int c, sigoff, ipok;
424
425     if (!dsiconfig || !options)
426         return;
427         
428     ipok = 0;
429     if (dsiconfig) {
430         status = dsiconfig->status;
431         maxstatuslen=sizeof(dsiconfig->status);
432         dsi = dsiconfig->obj.handle;
433         if (dsi->server.ss_family == AF_INET) { /* IPv4 */
434             const struct sockaddr_in *sa4 = (struct sockaddr_in *)&dsi->server;
435             ipok = sa4->sin_addr.s_addr ? 1 : 0;
436         } else { /* IPv6 */
437             const struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)&dsi->server;
438             for (int i=0; i<16; i++) {
439                 if (sa6->sin6_addr.s6_addr[i]) {
440                     ipok = 1;
441                     break;
442                 }
443             }
444         }
445     } else
446         dsi = NULL;
447
448     /*
449      * These routines must be called in order -- earlier calls
450      * set the offsets for later calls.
451      *
452      * using structs is a bad idea, but that's what the original code
453      * does. solaris, in fact, will segfault with them. so, now
454      * we just use the powers of #defines and memcpy.
455      *
456      * reply block layout (offsets are 16-bit quantities):
457      * machine type offset -> AFP version count offset ->
458      * UAM count offset -> vol icon/mask offset -> flags ->
459      *
460      * server name [padded to even boundary] -> signature offset ->
461      * network address offset ->
462      *
463      * at the appropriate offsets:
464      * machine type, afp versions, uams, server signature
465      * (16-bytes), network addresses, volume icon/mask 
466      */
467
468     status_flags(status,
469                  options->server_notif,
470                  (options->fqdn || ipok),
471                  options->passwdbits, 
472                  (options->k5service && options->k5realm && options->fqdn),
473                  options->flags);
474     /* returns offset to signature offset */
475     c = status_server(status, options->server ? options->server :
476                       options->hostname, options);
477     status_machine(status);
478     status_versions(status, dsi);
479     status_uams(status, options->uamlist);
480     if (options->flags & OPTION_CUSTOMICON)
481         status_icon(status, icon, sizeof(icon), c);
482     else
483         status_icon(status, apple_atalk_icon, sizeof(apple_atalk_icon), c);
484
485     sigoff = status_signature(status, &c, options);
486     /* c now contains the offset where the netaddress offset lives */
487
488     status_netaddress(status, &c, dsi, options);
489     /* c now contains the offset where the Directory Names Count offset lives */
490
491     statuslen = status_directorynames(status, &c, dsi, options);
492     /* c now contains the offset where the UTF-8 ServerName offset lives */
493
494     if ( statuslen < maxstatuslen) 
495         statuslen = status_utf8servername(status, &c, dsi, options);
496
497     if (dsiconfig) {
498         if ((options->flags & OPTION_CUSTOMICON) == 0) {
499             status_icon(status, apple_tcp_icon, sizeof(apple_tcp_icon), 0);
500         }
501         dsi_setstatus(dsi, status, statuslen);
502         dsiconfig->signature = status + sigoff;
503         dsiconfig->statuslen = statuslen;
504     }
505 }
506
507 /* set_signature()                                                    */
508 /*                                                                    */
509 /* If found in conf file, use it.                                     */
510 /* If not found in conf file, genarate and append in conf file.       */
511 /* If conf file don't exist, create and genarate.                     */
512 /* If cannot open conf file, use one-time signature.                  */
513 /* If -signature user:xxxxx, use it.                                  */
514
515 void set_signature(struct afp_options *options) {
516     char *usersign;
517     int fd, i;
518     struct stat tmpstat;
519     char *servername_conf;
520     int header = 0;
521     char buf[1024], *p;
522     FILE *fp = NULL, *randomp;
523     size_t len;
524     char *server_tmp;
525     
526     server_tmp = (options->server ? options->server : options->hostname);
527     if (strcmp(options->signatureopt, "auto") == 0) {
528         goto server_signature_auto;   /* default */
529     } else if (strcmp(options->signatureopt, "host") == 0) {
530         LOG(log_warning, logtype_afpd, "WARNING: option \"-signature host\" is obsoleted. Switching back to auto.", options->signatureopt);
531         goto server_signature_auto;   /* same as auto */
532     } else if (strncmp(options->signatureopt, "user", 4) == 0) {
533         goto server_signature_user;   /*  user string */
534     } else {
535         LOG(log_error, logtype_afpd, "ERROR: option \"-signature %s\" is not valid. Switching back to auto.", options->signatureopt);
536         goto server_signature_auto;   /* switch back to auto*/
537     }
538     
539 server_signature_user:
540     
541     /* Signature type is user string */
542     len = strlen(options->signatureopt);
543     if (len <= 5) {
544         LOG(log_warning, logtype_afpd, "WARNING: option \"-signature %s\" is not valid. Switching back to auto.", options->signatureopt);
545         goto server_signature_auto;
546     }
547     usersign = options->signatureopt + 5;
548     len = len - 5;
549     if (len > 16) {
550         LOG(log_warning, logtype_afpd, "WARNING: signature user string %s is very long !",  usersign);
551         len = 16;
552     } else if (len >= 3) {
553         LOG(log_info, logtype_afpd, "signature user string is %s.", usersign);
554     } else {
555         LOG(log_warning, logtype_afpd, "WARNING: signature user string %s is very short !",  usersign);
556     }
557     memset(options->signature, 0, 16);
558     memcpy(options->signature, usersign, len);
559     goto server_signature_done;
560     
561 server_signature_auto:
562     
563     /* Signature type is auto, using afp_signature.conf */
564     if (!stat(options->sigconffile, &tmpstat)) {                /* conf file exists? */
565         if ((fp = fopen(options->sigconffile, "r")) != NULL) {  /* read open? */
566             /* scan in the conf file */
567             while (fgets(buf, sizeof(buf), fp) != NULL) { 
568                 p = buf;
569                 while (p && isblank(*p))
570                     p++;
571                 if (!p || (*p == '#') || (*p == '\n'))
572                     continue;                             /* invalid line */
573                 if (*p == '"') {
574                     p++;
575                     if ((servername_conf = strtok( p, "\"" )) == NULL)
576                         continue;                         /* syntax error: invalid quoted servername */
577                 } else {
578                     if ((servername_conf = strtok( p, " \t" )) == NULL)
579                         continue;                         /* syntax error: invalid servername */
580                 }
581                 p = strchr(p, '\0');
582                 p++;
583                 if (*p == '\0')
584                     continue;                             /* syntax error: missing signature */
585                 
586                 if (strcmp(server_tmp, servername_conf))
587                     continue;                             /* another servername */
588                 
589                 while (p && isblank(*p))
590                     p++;
591                 if ( 16 == sscanf(p, "%2hhX%2hhX%2hhX%2hhX%2hhX%2hhX%2hhX%2hhX%2hhX%2hhX%2hhX%2hhX%2hhX%2hhX%2hhX%2hhX",
592                                   &options->signature[ 0], &options->signature[ 1],
593                                   &options->signature[ 2], &options->signature[ 3],
594                                   &options->signature[ 4], &options->signature[ 5],
595                                   &options->signature[ 6], &options->signature[ 7],
596                                   &options->signature[ 8], &options->signature[ 9],
597                                   &options->signature[10], &options->signature[11],
598                                   &options->signature[12], &options->signature[13],
599                                   &options->signature[14], &options->signature[15]
600                          )) {
601                     fclose(fp);
602                     goto server_signature_done;                 /* found in conf file */
603                 }
604             }
605             if ((fp = freopen(options->sigconffile, "a+", fp)) != NULL) { /* append because not found */
606                 fseek(fp, 0L, SEEK_END);
607                 if(ftell(fp) == 0) {                     /* size = 0 */
608                     header = 1;
609                     goto server_signature_random;
610                 } else {
611                     fseek(fp, -1L, SEEK_END);
612                     if(fgetc(fp) != '\n') fputc('\n', fp); /* last char is \n? */
613                     goto server_signature_random;
614                 }                    
615             } else {
616                 LOG(log_error, logtype_afpd, "ERROR: Cannot write in %s (%s). Using one-time signature.",
617                     options->sigconffile, strerror(errno));
618                 goto server_signature_random;
619             }
620         } else {
621             LOG(log_error, logtype_afpd, "ERROR: Cannot read %s (%s). Using one-time signature.",
622                 options->sigconffile, strerror(errno));
623             goto server_signature_random;
624         }
625     } else { /* conf file don't exist */
626         if (( fd = creat(options->sigconffile, 0644 )) < 0 ) {
627             LOG(log_error, logtype_atalkd, "Cannot create %s (%s). Using one-time signature.",
628                 options->sigconffile, strerror(errno));
629             goto server_signature_random;
630         }
631         if (( fp = fdopen( fd, "w" )) == NULL ) {
632             LOG(log_error, logtype_atalkd, "Cannot fdopen %s (%s). Using one-time signature.",
633                 options->sigconffile, strerror(errno));
634             close(fd);
635             goto server_signature_random;
636         }
637         header = 1;
638         goto server_signature_random;
639     }
640     
641 server_signature_random:
642     
643     /* generate signature from random number */
644     randombytes(options->signature, 16);
645
646     if (fp && header) { /* conf file is created or size=0 */
647         fprintf(fp, "# DON'T TOUCH NOR COPY THOUGHTLESSLY!\n");
648         fprintf(fp, "# This file is auto-generated by afpd.\n");
649         fprintf(fp, "# \n");
650         fprintf(fp, "# ServerSignature is unique identifier used to prevent logging on to\n");
651         fprintf(fp, "# the same server twice.\n");
652         fprintf(fp, "# \n");
653         fprintf(fp, "# If setting \"-signature user:xxxxx\" in afpd.conf, this file is not used.\n\n");
654     }
655     
656     if (fp) {
657         fprintf(fp, "\"%s\"\t", server_tmp);
658         for (i=0 ; i<16 ; i++) {
659             fprintf(fp, "%02X", (options->signature)[i]);
660         }
661         fprintf(fp, "%s", "\n");
662         fclose(fp);
663     }
664     
665 server_signature_done:
666     
667     /* retrun */
668     LOG(log_info, logtype_afpd,
669         " \"%s\"'s signature is  %02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
670         server_tmp,
671         (options->signature)[ 0], (options->signature)[ 1],
672         (options->signature)[ 2], (options->signature)[ 3],
673         (options->signature)[ 4], (options->signature)[ 5],
674         (options->signature)[ 6], (options->signature)[ 7],
675         (options->signature)[ 8], (options->signature)[ 9],
676         (options->signature)[10], (options->signature)[11],
677         (options->signature)[12], (options->signature)[13],
678         (options->signature)[14], (options->signature)[15]);
679     
680     return;
681 }
682
683 /* this is the same as asp/dsi_getstatus */
684 int afp_getsrvrinfo(AFPObj *obj, char *ibuf _U_, size_t ibuflen _U_, char *rbuf, size_t *rbuflen)
685 {
686     AFPConfig *config = obj->config;
687
688     memcpy(rbuf, config->status, config->statuslen);
689     *rbuflen = config->statuslen;
690     return AFP_OK;
691 }