Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static int password_pipe(request_rec *r)
- {
- apr_table_t *e = r->subprocess_env;
- int fd, wfd;
- apr_size_t nbytes;
- apr_file_t *readp = NULL;
- apr_file_t *writep = NULL;
- const char *user, *pass, *auth, *userDN, *siepwd;
- char *ans;
- apr_status_t rv;
- user = r->user;
- pass = apr_table_get(r->notes, RQ_NOTES_USERPW);
- userDN = apr_table_get(r->notes, RQ_NOTES_USERDN);
- auth = apr_table_get(r->headers_in, "authorization");
- siepwd = ADM_NO_VALUE_STRING;
- if (!user) user = ADM_NO_VALUE_STRING;
- if (!pass) pass = ADM_NO_VALUE_STRING;
- if (!auth) auth = ADM_NO_VALUE_STRING;
- if (!userDN) userDN = ADM_NO_VALUE_STRING;
- ans = (char*)apr_palloc(r->pool, strlen(user) + strlen(ADM_USER_STRING) +
- strlen(pass) + strlen(ADM_PASS_STRING) +
- strlen(auth) + strlen(ADM_AUTH_STRING) +
- strlen(userDN) + strlen(ADM_USERDN_STRING) +
- strlen(ADM_SIEPWD_STRING) +
- strlen(siepwd) + 16);
- sprintf(ans, "%s%s\n%s%s\n%s%s\n%s%s\n%s%s\n", ADM_USER_STRING, user,
- ADM_PASS_STRING, pass,
- ADM_AUTH_STRING, auth,
- ADM_USERDN_STRING, userDN,
- ADM_SIEPWD_STRING,
- siepwd);
- rv = apr_file_pipe_create(&readp, &writep, r->pool);
- if (rv != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
- "mod_admserv: Unable to create pipe");
- return HTTP_INTERNAL_SERVER_ERROR;
- }
- /* Get the low-level file descriptor */
- apr_os_file_get(&fd, readp);
- apr_os_file_get(&wfd, writep);
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL,
- "password_pipe(): created pipe read %d write %d", fd, wfd);
- /* Register a cleanup callback so this gets closed at the end of the
- request. */
- apr_pool_cleanup_register(r->pool, (void *)((intptr_t)fd), close_pipe,
- apr_pool_cleanup_null);
- /* Send this to the client so they know what fd to read from */
- apr_table_setn(e, "PASSWORD_PIPE", apr_itoa(r->pool, fd));
- nbytes = strlen(ans);
- apr_file_write(writep, ans, &nbytes);
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL,
- "password_pipe(): wrote %d bytes", (int)nbytes);
- /* Close the writing side, we don't need this any more */
- apr_file_close(writep);
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL,
- "password_pipe(): closed write descriptor");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement