Richard
Thanks for the reply. Here is the patch against cvs head as of today.
The original commentry follows
Best Regards
Andrew
> Here is a little patch to allow usage of the wildcard entry in the
> (YP/NIS+) automount map. Basic operation is a follows; In a
> automounting environment it is common to use a map like this with a
> catchall wildcard entry.
>
> user1server-a:/path/to/disk1/user1 # explicit entry
> user2server-b:/path/to/disk2/& # slightly less work for admin
> - looked up key(user2) is substituted back in for ampersand
> * server-c:/path/to/disk3/& # any user not in the map
> explicitly, gets this entry again with key replacement.
>
> I have added code for both YP and NIS+ but have not had the
> opportunity to test NIS+ as I don't have a running NIS+ domain. You
> will notice the change in substitute.c. The present behavior is not
> correct in any share but happens to work in the [homes] one since both
> username and resolved sharename are the same. So currently when using
> %N / %p in a share called [test] the automount server is looked up in
> the map with
> key(username) but the path is looked up in the same map with key(test).
On Tuesday 21 Jan 2003 8:04 pm, Richard Sharpe wrote:
> On Tue, 21 Jan 2003, Andrew Bird (Sphere Systems) wrote:
> > Hi all
> > I have been following samba-technical for a couple of years now. I have
> > seen in the past, intense debate over whether patches should / or not be
> > included. I am quite surprised that my first code patch to the list has
> > been met with indifference. I provoke neither approval nor disapproval.
> >
> > Guess you're all too busy coding.
>
> Sigh. Sometimes things get dropped.
>
> Can you resend it.
>
> Was it against Samba 2.2.x? That branch is now not receiving any
> attention. If it was against 2.2.x, could you port the patch to the Head
> branch?
>
> Regards
> -
> Richard Sharpe, rsharpe[at]ns.aus.com, rsharpe[at]samba.org,
> sharpe[at]ethereal.com, http://www.richardsharpe.com
diff -r -u samba-head-21-01-2003/source/lib/substitute.c samba-head-21-01-2003.automount/source/lib/substitute.c
--- samba-head-21-01-2003/source/lib/substitute.c Wed Nov 20 00:39:51 2002
+++ samba-head-21-01-2003.automount/source/lib/substitute.c Tue Jan 21 22:13:04 2003
@@ -404,7 +404,13 @@
* "path =" string in [homes] and so needs the
* service name, not the username. */
case 'p':
- string_sub(p,"%p", automount_path(lp_servicename(snum)), l);
+ string_sub(p,"%p", automount_path(user),l);
+/* The %p (NIS server path) code is
+* here as it is used instead of the default
+* "path =" string in [homes]. The %p should
+* return the automount path when looked up in
+* the automount map with the username as the
+* key */
break;
case '\0':
p++;
diff -r -u samba-head-21-01-2003/source/lib/util.c samba-head-21-01-2003.automount/source/lib/util.c
--- samba-head-21-01-2003/source/lib/util.c Fri Jan 17 20:57:23 2003
+++ samba-head-21-01-2003.automount/source/lib/util.c Tue Jan 21 21:15:33 2003
@@ -1196,7 +1196,7 @@
char *nis_map = (char *)lp_nis_home_map_name();
char buffer[NIS_MAXATTRVAL + 1];
- nis_result *result;
+ nis_result *result,*wildresult;
nis_object *object;
entry_obj *entry;
@@ -1205,6 +1205,20 @@
DEBUG(5, ("NIS+ querystring: %s\n", buffer));
if (result = nis_list(buffer, FOLLOW_PATH|EXPAND_NAME|HARD_LOOKUP, NULL, NULL)) {
+ if(result->status == NIS_NOTFOUND) {
+slprintf(buffer, sizeof(buffer)-1, "[key=*],%s", nis_map);
+if (wildresult = nis_list(buffer, FOLLOW_PATH|EXPAND_NAME|HARD_LOOKUP, NULL, NULL)) {
+ if (wildresult->status == NIS_SUCCESS) {
+ DEBUG(3, ("NIS+ query failed: using wildcard entry for \"%s\" in map \"%s\"\n",
+ user_name, nis_map));
+ nis_freeresult(result);
+ result=wildresult;
+ } else {
+ nis_freeresult(wildresult);
+ }
+}
+ }
+
if (result->status != NIS_SUCCESS) {
DEBUG(3, ("NIS+ query failed: %s\n", nis_sperrno(result->status)));
fstrcpy(last_key, ""); pstrcpy(last_value, "");
@@ -1255,7 +1269,15 @@
nis_error = 0;
} else {
if ((nis_error = yp_match(nis_domain, nis_map, user_name, strlen(user_name),
+&nis_result, &nis_result_len)) == YPERR_KEY) { /* check for wildcard entry */
+ if ((nis_error = yp_match(nis_domain, nis_map,"*", 1,
&nis_result, &nis_result_len)) == 0) {
+DEBUG(3, ("YP Key not found: using wildcard entry for \"