OpenSolaris

Printable Version Enter a New Search
Bug ID 6657760
Synopsis libsmb should look for an interposition library for local user management
State 10-Fix Delivered (Fix available in build)
Category:Subcategory utility:cifs
Keywords
Responsible Engineer Hoa V Nguyen
Reported Against
Duplicate Of
Introduced In solaris_nevada
Commit to Fix snv_84
Fixed In snv_84
Release Fixed solaris_nevada(snv_84)
Related Bugs 6617183 , 6663522
Submit Date 31-January-2008
Last Update Date 9-May-2008
Description
[From Mike S, 1/30/2008]

libsmb should look for an interposition library that replaces the three smb_pwd_* routines.  This is how it would work:

In libsmb.so.1 do this:

struct {
	int (*smb_pwd_getpasswd)( ... );
	int (*smb_pwd_setcntl)( ... );
	int (*smb_pwd_setpasswd)( ... );
} smb_pwd_ops;

void *smb_pwd_hdl;

#pragma init (smb_init)

void
smb_init(void)
{
	smb_pwd_hdl = dlopen("/usr/lib/smb/libsmb_pwd.so", RTLD_LOCAL);

	if (smb_pwd_hdl == NULL)
		return; /* interposition library not found */

	smb_pwd_ops.smb_pwd_getpasswd =
	    (int (*)())dlsym(smb_pwd_hdl, "smb_pwd_getpasswd");

	smb_pwd_ops.smb_pwd_getpasswd =
	    (int (*)())dlsym(smb_pwd_hdl, "smb_pwd_setcntl");

	smb_pwd_ops.smb_pwd_getpasswd =
	    (int (*)())dlsym(smb_pwd_hdl, "smb_pwd_setpasswd");
}

and then you change each function to be hooked as you suggested, e.g.

int
smb_pwd_getpasswd( ... )
{
	if (smb_pwd_ops.smb_pwd_getpasswd != NULL)
		return (smb_pwd_ops.smb_pwd_getpasswd( ... ));

	... do existing code
}

This isn't particularly hard either.  The key is that since multiple things depend on libsmb, we can't force them to call some registration function: the registration has to be done automatically when libsmb is loaded, by seeing that our interposition binary is on the filesystem.
Work Around
N/A
Comments
N/A