1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
10
* Sun Industry Standards Source License Version 1.2
11
* =================================================
12
* The contents of this file are subject to the Sun Industry Standards
13
* Source License Version 1.2 (the "License"); You may not use this file
14
* except in compliance with the License. You may obtain a copy of the
15
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
17
* Software provided under this License is provided on an "AS IS" basis,
18
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21
* See the License for the specific provisions governing your rights and
22
* obligations concerning the Software.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
38
#include <sys/types.h>
39
#include <sys/socket.h>
40
#include <netinet/in.h>
44
#include <sys/param.h>
48
#include <gssapi/gssapi_generic.h>
52
#include "sge_gsslib.h"
54
/* #include "sge_language.h" */
60
p = (NULL == (p = strrchr(progname,'/'))) ? progname : p+1;
61
fprintf(stderr, MSG_GSS_WRITECRED_USAGE_S , p);
62
fprintf(stderr, "\n");
68
main(int argc, char **argv)
70
gss_buffer_desc client_cred;
73
char lenbuf[GSSLIB_INTSIZE];
77
fd = SGE_OPEN3(argv[1], O_WRONLY|O_CREAT, 0700);
79
fprintf(stderr, MSG_GSS_COULDNOTOPENXY_SS , argv[1], strerror(errno));
80
fprintf(stderr, "\n");
87
* read client credentials buffer from stdin
90
fprintf(stderr, "%s\n", MSG_GSS_READINGCREDENTIALLENGTH);
92
if (read(0, lenbuf, sizeof(lenbuf)) != sizeof(lenbuf)) {
93
fprintf(stderr, "%s\n", MSG_GSS_FAILEDREADINGCREDENTIALLENGTHFROMSTDIN);
96
client_cred.length = gsslib_unpackint(lenbuf);
98
fprintf(stderr, MSG_GSS_READLENGTHOFX_I, (int)client_cred.length);
99
fprintf(stderr, "\n");
101
if ((client_cred.value = (char *)malloc(client_cred.length)) == 0) {
102
fprintf(stderr, MSG_GSS_COULDNOTALLOCATEXBYTESFORCREDENTIALS_I,
103
(int)client_cred.length);
104
fprintf(stderr, "\n");
108
if (read(0, client_cred.value, client_cred.length) != client_cred.length) {
109
fprintf(stderr, "%s\n", MSG_GSS_FAILEDREADINGCREDENTIALLENGTHFROMSTDIN);
113
fprintf(stderr, MSG_GSS_READXBYTES_I, (int)client_cred.length);
114
fprintf(stderr, "\n");
117
* write credentials to stdout
120
if (client_cred.length) {
121
gsslib_packint(client_cred.length, lenbuf);
122
write(fd, lenbuf, sizeof(lenbuf));
123
write(fd, client_cred.value, client_cred.length);
124
fprintf(stderr, MSG_GSS_WROTEXBYTES_I , (int)client_cred.length);
125
fprintf(stderr, "\n");
127
fprintf(stderr, MSG_GSS_WRITECREDNOCREDENTIALSFOUND);
128
fprintf(stderr, "\n");