The clnt_create(KEYSERVSOCK, CRYPT_PROG, CRYPT_VERS, "unix") hacks
were removed and replaced them with clnt_tp_create, now the af_local support is fixed. I also removed the hack how rpcinfo contacted rpcbind, now we can relay on clnt_tp_create create the client-handle for us. Only rpcbind itself needs a hardcoded socket-path. Submitted by: mbr Also add $FreeBSD
This commit is contained in:
parent
26d0e65f67
commit
8858373f83
@ -42,10 +42,6 @@
|
|||||||
static const char rcsid[] = "$FreeBSD$";
|
static const char rcsid[] = "$FreeBSD$";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef KEYSERVSOCK
|
|
||||||
#define KEYSERVSOCK "/var/run/keyservsock"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
int
|
||||||
_des_crypt_call(buf, len, dparms)
|
_des_crypt_call(buf, len, dparms)
|
||||||
char *buf;
|
char *buf;
|
||||||
@ -55,12 +51,27 @@ _des_crypt_call(buf, len, dparms)
|
|||||||
CLIENT *clnt;
|
CLIENT *clnt;
|
||||||
desresp *result_1;
|
desresp *result_1;
|
||||||
desargs des_crypt_1_arg;
|
desargs des_crypt_1_arg;
|
||||||
int stat;
|
struct netconfig *nconf;
|
||||||
|
void *localhandle;
|
||||||
|
int stat;
|
||||||
|
|
||||||
clnt = clnt_create(KEYSERVSOCK, CRYPT_PROG, CRYPT_VERS, "unix");
|
nconf = NULL;
|
||||||
if (clnt == (CLIENT *) NULL) {
|
localhandle = setnetconfig();
|
||||||
|
while ((nconf = getnetconfig(localhandle)) != NULL) {
|
||||||
|
if (nconf->nc_protofmly != NULL &&
|
||||||
|
strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (nconf == NULL) {
|
||||||
|
warnx("getnetconfig: %s", nc_sperror());
|
||||||
return(DESERR_HWERROR);
|
return(DESERR_HWERROR);
|
||||||
}
|
}
|
||||||
|
clnt = clnt_tp_create(NULL, CRYPT_PROG, CRYPT_VERS, nconf);
|
||||||
|
if (clnt == (CLIENT *) NULL) {
|
||||||
|
endnetconfig(localhandle);
|
||||||
|
return(DESERR_HWERROR);
|
||||||
|
}
|
||||||
|
endnetconfig(localhandle);
|
||||||
|
|
||||||
des_crypt_1_arg.desbuf.desbuf_len = len;
|
des_crypt_1_arg.desbuf.desbuf_len = len;
|
||||||
des_crypt_1_arg.desbuf.desbuf_val = buf;
|
des_crypt_1_arg.desbuf.desbuf_val = buf;
|
||||||
|
@ -354,7 +354,6 @@ char *get_yp_master(getserver)
|
|||||||
char *mastername;
|
char *mastername;
|
||||||
int rval, localport;
|
int rval, localport;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char *sockname = YP_SOCKNAME;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sometimes we are called just to probe for rpc.yppasswdd and
|
* Sometimes we are called just to probe for rpc.yppasswdd and
|
||||||
@ -407,7 +406,7 @@ char *get_yp_master(getserver)
|
|||||||
/* See if _we_ are the master server. */
|
/* See if _we_ are the master server. */
|
||||||
if (!force_old && !getuid() && (localport = getrpcport("localhost",
|
if (!force_old && !getuid() && (localport = getrpcport("localhost",
|
||||||
YPPASSWDPROG, YPPASSWDPROC_UPDATE, IPPROTO_UDP)) != 0) {
|
YPPASSWDPROG, YPPASSWDPROC_UPDATE, IPPROTO_UDP)) != 0) {
|
||||||
if (localport == rval && stat(sockname, &st) != -1) {
|
if (localport == rval) {
|
||||||
suser_override = 1;
|
suser_override = 1;
|
||||||
mastername = "localhost";
|
mastername = "localhost";
|
||||||
}
|
}
|
||||||
@ -433,12 +432,14 @@ void yp_submit(pw)
|
|||||||
{
|
{
|
||||||
struct yppasswd yppasswd;
|
struct yppasswd yppasswd;
|
||||||
struct master_yppasswd master_yppasswd;
|
struct master_yppasswd master_yppasswd;
|
||||||
|
struct netconfig *nconf;
|
||||||
|
void *localhandle;
|
||||||
CLIENT *clnt;
|
CLIENT *clnt;
|
||||||
char *master, *password;
|
char *master, *password;
|
||||||
int *status = NULL;
|
int *status = NULL;
|
||||||
struct rpc_err err;
|
struct rpc_err err;
|
||||||
char *sockname = YP_SOCKNAME;
|
|
||||||
|
|
||||||
|
nconf = NULL;
|
||||||
_use_yp = 1;
|
_use_yp = 1;
|
||||||
|
|
||||||
/* Get NIS master server name */
|
/* Get NIS master server name */
|
||||||
@ -490,13 +491,26 @@ void yp_submit(pw)
|
|||||||
|
|
||||||
if (suser_override) {
|
if (suser_override) {
|
||||||
/* Talk to server via AF_UNIX socket. */
|
/* Talk to server via AF_UNIX socket. */
|
||||||
clnt = clnt_create(sockname, MASTER_YPPASSWDPROG,
|
localhandle = setnetconfig();
|
||||||
MASTER_YPPASSWDVERS, "unix");
|
while ((nconf = getnetconfig(localhandle)) != NULL) {
|
||||||
|
if (nconf->nc_protofmly != NULL &&
|
||||||
|
strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (nconf == NULL) {
|
||||||
|
warnx("getnetconfig: %s", nc_sperror());
|
||||||
|
pw_error(tempname, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
clnt = clnt_tp_create(NULL, MASTER_YPPASSWDPROG,
|
||||||
|
MASTER_YPPASSWDVERS, nconf);
|
||||||
if (clnt == NULL) {
|
if (clnt == NULL) {
|
||||||
warnx("failed to contact rpc.yppasswdd: %s",
|
warnx("failed to contact rpc.yppasswdd: %s",
|
||||||
clnt_spcreateerror(master));
|
clnt_spcreateerror(master));
|
||||||
|
endnetconfig(localhandle);
|
||||||
pw_error(tempname, 0, 1);
|
pw_error(tempname, 0, 1);
|
||||||
}
|
}
|
||||||
|
endnetconfig(localhandle);
|
||||||
} else {
|
} else {
|
||||||
/* Create a handle to yppasswdd. */
|
/* Create a handle to yppasswdd. */
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* 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
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* $FreeBSD$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef YP
|
#ifdef YP
|
||||||
@ -55,14 +57,16 @@ yp_passwd(char *user)
|
|||||||
{
|
{
|
||||||
struct yppasswd yppasswd;
|
struct yppasswd yppasswd;
|
||||||
struct master_yppasswd master_yppasswd;
|
struct master_yppasswd master_yppasswd;
|
||||||
|
struct netconfig *nconf;
|
||||||
|
void *localhandle;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
CLIENT *clnt;
|
CLIENT *clnt;
|
||||||
struct rpc_err err;
|
struct rpc_err err;
|
||||||
char *master;
|
char *master;
|
||||||
int *status = NULL;
|
int *status = NULL;
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
char *sockname = YP_SOCKNAME;
|
|
||||||
|
|
||||||
|
nconf = NULL;
|
||||||
_use_yp = 1;
|
_use_yp = 1;
|
||||||
|
|
||||||
uid = getuid();
|
uid = getuid();
|
||||||
@ -144,12 +148,24 @@ for other users");
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (suser_override) {
|
if (suser_override) {
|
||||||
if ((clnt = clnt_create(sockname, MASTER_YPPASSWDPROG,
|
localhandle = setnetconfig();
|
||||||
MASTER_YPPASSWDVERS, "unix")) == NULL) {
|
while ((nconf = getnetconfig(localhandle)) != NULL) {
|
||||||
warnx("failed to contact rpc.yppasswdd on host %s: %s",
|
if (nconf->nc_protofmly != NULL &&
|
||||||
master, clnt_spcreateerror(""));
|
strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (nconf == NULL) {
|
||||||
|
warnx("getnetconfig: %s", nc_sperror());
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
if ((clnt = clnt_tp_create(NULL, MASTER_YPPASSWDPROG,
|
||||||
|
MASTER_YPPASSWDVERS, nconf)) == NULL) {
|
||||||
|
warnx("failed to contact rpc.yppasswdd on host %s: %s",
|
||||||
|
master, clnt_spcreateerror(""));
|
||||||
|
endnetconfig(localhandle);
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
endnetconfig(localhandle);
|
||||||
} else {
|
} else {
|
||||||
if ((clnt = clnt_create(master, YPPASSWDPROG,
|
if ((clnt = clnt_create(master, YPPASSWDPROG,
|
||||||
YPPASSWDVERS, "udp")) == NULL) {
|
YPPASSWDVERS, "udp")) == NULL) {
|
||||||
|
@ -321,22 +321,24 @@ main(int argc, char **argv)
|
|||||||
static CLIENT *
|
static CLIENT *
|
||||||
local_rpcb(u_long prog, u_long vers)
|
local_rpcb(u_long prog, u_long vers)
|
||||||
{
|
{
|
||||||
struct netbuf nbuf;
|
void *localhandle;
|
||||||
struct sockaddr_un sun;
|
struct netconfig *nconf;
|
||||||
int sock;
|
CLIENT *clnt;
|
||||||
|
|
||||||
memset(&sun, 0, sizeof sun);
|
localhandle = setnetconfig();
|
||||||
sock = socket(AF_LOCAL, SOCK_STREAM, 0);
|
while ((nconf = getnetconfig(localhandle)) != NULL) {
|
||||||
if (sock < 0)
|
if (nconf->nc_protofmly != NULL &&
|
||||||
return NULL;
|
strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (nconf == NULL) {
|
||||||
|
warnx("getnetconfig: %s", nc_sperror());
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
sun.sun_family = AF_LOCAL;
|
clnt = clnt_tp_create(NULL, prog, vers, nconf);
|
||||||
strcpy(sun.sun_path, _PATH_RPCBINDSOCK);
|
endnetconfig(localhandle);
|
||||||
nbuf.len = sun.sun_len = SUN_LEN(&sun);
|
return clnt;
|
||||||
nbuf.maxlen = sizeof (struct sockaddr_un);
|
|
||||||
nbuf.buf = &sun;
|
|
||||||
|
|
||||||
return clnt_vc_create(sock, &nbuf, prog, vers, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PORTMAP
|
#ifdef PORTMAP
|
||||||
|
Loading…
Reference in New Issue
Block a user