/*
* Copyright (c) 2000, Boris Popov
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Boris Popov.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
*/
#include <fcntl.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <pwd.h>
#include <grp.h>
#include <unistd.h>
#include <libintl.h>
#include "smbfs_lib.h"
#include "smbfs_private.h"
static int smbfs_print_file(smb_ctx_t *, char *, int);
static int smbfs_open_printer(struct smb_ctx *, const char *, int, int);
/*
* Prints file or data from stdin using the given printer share UNC path and
* username. If username is NULL, then the Solaris username and the SMB
* domain from SMF are taken. The password to authenticate the user is taken
* from the password keychain, standard input, or prompt if standard input is
* a tty. If the password from keychain or prompt does not successfully
* authenticate the user then a password will be prompted for again.
*
* Values we get from the command that are copied to the smb_ctx structure
* should not be overwritten later on, so we mark values from the command
* as "from CMD" for smbfs_ctx_setXXXX APIs.
*
* NOTE: The again label with goto statement does not cause an infinite loop
* since smb_get_authentication() will prompt the user if standard input is
* a tty or returns error on retry (no data) if standard input is not a tty.
*/
int
{
return (EINVAL);
if (error)
goto out;
if (error)
goto out;
if (dom) {
if (error)
goto out;
}
if (usr) {
if (error)
goto out;
}
}
if (error)
goto out;
file = 0; /* stdin */
filename = "stdin";
} else {
if (file < 0) {
goto out;
}
}
if (error)
goto out;
}
if (err2 == 0)
goto again;
}
if (error) {
goto out;
}
if (error) {
goto out;
}
out:
/* don't close stdin (file=0) */
if (file > 0)
return (error);
}
/*
* Documentation for OPEN_PRINT_FILE is scarce.
* It's in a 1996 MS doc. entitled:
* SMB FILE SHARING PROTOCOL
*
* The extra parameters are:
* SetupLength: what part of the file is printer setup
* Mode: text or graphics (raw data)
* IdentifierString: job title
*/
enum {
};
static int
{
int error = 0;
if (pfd < 0) {
return (errno);
}
offset = 0;
for (;;) {
if (rcnt < 0) {
break;
}
if (rcnt == 0)
break;
if (wcnt < 0) {
break;
}
smbfs_error("incomplete write to spool file\n", 0);
break;
}
}
(void) smbfs_fh_close(pfd);
return (error);
}
static int
{
if (tlen >= SMBIOC_MAX_NAME)
return (EINVAL);
/*
* Will represent this SMB-level open as a new
* open device handle. Get one, then duplicate
* the driver session and tree bindings.
*/
new_fd = smbfs_open_driver();
if (new_fd < 0)
return (errno);
goto errout;
}
/*
* Do the SMB-level open with the new dev handle.
*/
goto errout;
}
return (new_fd);
return (-1);
}
/* See smb_fh_close */