Date: Mon, 27 Jul 2009 11:33:16 GMT From: Jonathan Anderson <jona@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 166612 for review Message-ID: <200907271133.n6RBXGos062624@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=166612 Change 166612 by jona@jona-trustedbsd-belle-vmware on 2009/07/27 11:32:34 Implemented ua_powerbox() Affected files ... .. //depot/projects/trustedbsd/capabilities/src/lib/libuserangel/libuserangel.c#11 edit Differences ... ==== //depot/projects/trustedbsd/capabilities/src/lib/libuserangel/libuserangel.c#11 (text+ko) ==== @@ -324,6 +324,53 @@ } +int ua_powerbox(struct ua_powerbox_options *options, + int fds[], char *names[], int *len) +{ + if(angel < 0) angel = ua_find(); + if(angel < 0) return -1; + + struct ua_datum *data[2]; + data[0] = ua_marshall_int(UA_POWERBOX); + data[1] = ua_marshall_powerbox(options); + + for(int i = 0; i < 2; i++) + { + if(ua_send(angel, data[i], NULL, 0) < 0) return -1; + free(data[i]); + } + + + // retrieve the file descriptor(s) + struct ua_datum *fdcountd = ua_recv(angel, NULL, NULL); + if(!fdcountd) return -1; + + if(ua_unmarshall_int(fdcountd, len) < 0) return -1; + + uint32_t fdcount = *len; + int32_t fdarray[fdcount]; + + struct ua_datum *fd_datum = ua_recv(angel, fdarray, &fdcount); + if(!fd_datum) return -1; + *len = fdcount; + + int buflen = 1024; + char buffer[buflen]; + for(unsigned int i = 0; i < fdcount; i++) + { + fds[i] = fdarray[i]; + + int namelen = buflen; + if(ua_unmarshall_string(fd_datum, buffer, &namelen) < 0) return -1; + + names[i] = (char*) malloc(namelen); + memcpy(names[i], buffer, namelen); + } + + return 0; +} + + int ua_send(int sock, datum *d, int32_t fds[], int32_t fdlen) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907271133.n6RBXGos062624>
