nfs-utils patches for nfsv4.0 callbacks
Subsystems (2)
NFSv4.0 callbacks over krb5 have been broken for a while. With the following three patches I've at least witnessed a succesful null callback.
--b.
PATCH 1/3 gssd: fix strncmp bug causing client removals
From: root <[email protected]>
Both dirname and pdir are null-terminated strings, so there's no reason I can see for the strncmp.
And this gives the wrong result when comparing the "nfsd" and "nfsd4_cb" directories! The results were callback clients being removed immediately after creation, when lack of a client with the corresponding name under "nfsd" lead gssd to believe it had disappeared from "nfsd4_cb".
--- utils/gssd/gssd_proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
utils/gssd/gssd_proc.c +1 -1
@@ -525,7 +525,7 @@ update_old_clients(struct dirent **namelist, int size, char *pdir)/* only compare entries in the global list that are from the * same pipefs parent directory as "pdir" */ -if (strncmp (clp->dirname, pdir,strlen (pdir)) !=0 )continue ; +if (strcmp (clp->dirname, pdir) !=0 )continue ; stillhere =0 ;for (i=0 ; i < size; i++) {
Signature · 1 line
1.8.3.1
Re: [PATCH 1/3] gssd: fix strncmp bug causing client removals
Quoted 1 line · J. Bruce Fields
From: root <[email protected]>
Ugh, sorry. I'll just resend all three of these with the authors fixed.
--b.
PATCH v2 1/3 gssd: fix strncmp bug causing client removals
In reply to J. Bruce FieldsFrom: "J. Bruce Fields" <[email protected]>
Both dirname and pdir are null-terminated strings, so there's no reason I can see for the strncmp.
And this gives the wrong result when comparing the "nfsd" and "nfsd4_cb" directories! The results were callback clients being removed immediately after creation, when lack of a client with the corresponding name under "nfsd" lead gssd to believe it had disappeared from "nfsd4_cb".
--- utils/gssd/gssd_proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
utils/gssd/gssd_proc.c +1 -1
@@ -525,7 +525,7 @@ update_old_clients(struct dirent **namelist, int size, char *pdir)/* only compare entries in the global list that are from the * same pipefs parent directory as "pdir" */ -if (strncmp (clp->dirname, pdir,strlen (pdir)) !=0 )continue ; +if (strcmp (clp->dirname, pdir) !=0 )continue ; stillhere =0 ;for (i=0 ; i < size; i++) {
Signature · 1 line
1.8.3.1
PATCH v2 2/3 gssd: don't use tgtname to find our keytab
From: "J. Bruce Fields" <[email protected]>
The tgtname is of the form service@hostname. It's not a hostname, and attempting to look it up here just causes failure of any upcall with a "target=" field (currently, any upcall on behalf of an nfsv4.0 callback).
I think the theory was that knowning that target= name might help pick the right keytab, but I don't really know if that's helpful. For now, just stop trying to do this.
--- utils/gssd/gssd_proc.c | 3 +-- utils/gssd/krb5_util.c | 10 +++------- utils/gssd/krb5_util.h | 3 +-- 3 files changed, 5 insertions(+), 11 deletions(-)
utils/gssd/gssd_proc.c +1 -2
@@ -1035,8 +1035,7 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname,int success =0 ; do { gssd_refresh_krb5_machine_credential(clp->servername, - NULL, service, - tgtname); + NULL, service); /* * Get a list of credential cache names and try each * of them until one works or we've tried them all
utils/gssd/krb5_util.c +3 -7
@@ -1149,7 +1149,7 @@ gssd_get_krb5_machine_cred_list(char ***list)if (ple->ccname) {/* Make sure cred is up-to-date before returning it */ retval =gssd_refresh_krb5_machine_credential (NULL , ple, -NULL ,NULL ); +NULL );if (retval)continue ;if (i +1 > listsize) {
@@ -1240,8 +1240,7 @@ gssd_destroy_krb5_machine_creds(void)int gssd_refresh_krb5_machine_credential (char *hostname,struct gssd_k5_kt_princ *ple, -char *service, -char *tgtname) +char *service) {krb5_error_code code =0 ;krb5_context context;
@@ -1280,10 +1279,7 @@ gssd_refresh_krb5_machine_credential(char *hostname,if (ple ==NULL ) {krb5_keytab_entry kte; -if (tgtname ==NULL ) - tgtname = hostname; - - code =find_keytab_entry (context, kt, tgtname, &kte, svcnames); + code =find_keytab_entry (context, kt, hostname, &kte, svcnames);if (code) { printerr(0, "ERROR: %s: no usable keytab entry found " "in keytab %s for connection with host %s\n",
utils/gssd/krb5_util.h +1 -2
@@ -31,8 +31,7 @@ void gssd_setup_krb5_machine_gss_ccache(char *servername);void gssd_destroy_krb5_machine_creds (void );int gssd_refresh_krb5_machine_credential (char *hostname,struct gssd_k5_kt_princ *ple, -char *service, -char *tgtname); +char *service);char *gssd_k5_err_msg (krb5_context context,krb5_error_code code);void gssd_k5_get_default_realm (char **def_realm);
Signature · 1 line
1.8.3.1
Re: [PATCHv2 2/3] gssd: don't use tgtname to find our keytab
Quoted 7 lines · J. Bruce Fields
From: "J. Bruce Fields" <[email protected]>
The tgtname is of the form service@hostname. It's not a hostname, and attempting to look it up here just causes failure of any upcall with a "target=" field (currently, any upcall on behalf of an nfsv4.0 callback).
Quoted 5 lines
I think the theory was that knowning that target= name might help pick the right keytab, but I don't really know if that's helpful. For now, just stop trying to do this.
Signed-off-by J. Bruce Fields <[email protected]>
Committed....
steved.
Quoted 70 lines
--- utils/gssd/gssd_proc.c | 3 +-- utils/gssd/krb5_util.c | 10 +++------- utils/gssd/krb5_util.h | 3 +-- 3 files changed, 5 insertions(+), 11 deletions(-)utils/gssd/gssd_proc.c +1
-2@@ -1035,8 +1035,7 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname,int success =0 ; do { gssd_refresh_krb5_machine_credential(clp->servername, - NULL, service, - tgtname); + NULL, service); /* * Get a list of credential cache names and try each * of them until one works or we've tried them allutils/gssd/krb5_util.c +3
-7@@ -1149,7 +1149,7 @@ gssd_get_krb5_machine_cred_list(char ***list)if (ple->ccname) {/* Make sure cred is up-to-date before returning it */ retval =gssd_refresh_krb5_machine_credential (NULL , ple, -NULL ,NULL ); +NULL );if (retval)continue ;if (i +1 > listsize) {@@ -1240,8 +1240,7 @@ gssd_destroy_krb5_machine_creds(void)int gssd_refresh_krb5_machine_credential (char *hostname,struct gssd_k5_kt_princ *ple, -char *service, -char *tgtname) +char *service) {krb5_error_code code =0 ;krb5_context context;@@ -1280,10 +1279,7 @@ gssd_refresh_krb5_machine_credential(char *hostname,if (ple ==NULL ) {krb5_keytab_entry kte; -if (tgtname ==NULL ) - tgtname = hostname; - - code =find_keytab_entry (context, kt, tgtname, &kte, svcnames); + code =find_keytab_entry (context, kt, hostname, &kte, svcnames);if (code) { printerr(0, "ERROR: %s: no usable keytab entry found " "in keytab %s for connection with host %s\n",utils/gssd/krb5_util.h +1
-2@@ -31,8 +31,7 @@ void gssd_setup_krb5_machine_gss_ccache(char *servername);void gssd_destroy_krb5_machine_creds (void );int gssd_refresh_krb5_machine_credential (char *hostname,struct gssd_k5_kt_princ *ple, -char *service, -char *tgtname); +char *service);char *gssd_k5_err_msg (krb5_context context,krb5_error_code code);void gssd_k5_get_default_realm (char **def_realm);
PATCH v2 3/3 gssd: let tgtname override clp->servicename
In reply to J. Bruce FieldsFrom: "J. Bruce Fields" <[email protected]>
When the kernel provides an explicit "target=" name in the upcall, that should override the name in clp->servicename.
--- utils/gssd/gssd_proc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
utils/gssd/gssd_proc.c +9 -6
@@ -822,6 +822,7 @@ set_port:*/ static int create_auth_rpc_client(struct clnt_info *clp, + char *tgtname, CLIENT **clnt_return, AUTH **auth_return, uid_t uid,
@@ -926,14 +927,16 @@ create_auth_rpc_client(struct clnt_info *clp, clnt_spcreateerror(rpc_errmsg)); goto out_fail; } +if (!tgtname) + tgtname = clp->servicename; -printerr (2 ,"creating context with server %s\n" , clp->servicename); - auth =authgss_create_default (rpc_clnt, clp->servicename, &sec); +printerr (2 ,"creating context with server %s\n" , tgtname); + auth =authgss_create_default (rpc_clnt, tgtname, &sec);if (!auth) {/* Our caller should print appropriate message */ printerr (2 ,"WARNING: Failed to create krb5 context for " "user with uid %d for server %s\n" , - uid, clp->servername); + uid, tgtname); goto out_fail; }
@@ -1015,7 +1018,7 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname,/* Try first to acquire credentials directly via GSSAPI */ err =gssd_acquire_user_cred (uid, &gss_cred);if (!err) - create_resp =create_auth_rpc_client (clp, &rpc_clnt, &auth, uid, + create_resp =create_auth_rpc_client (clp, tgtname, &rpc_clnt, &auth, uid,AUTHTYPE_KRB5 , gss_cred);/* if create_auth_rplc_client fails try the traditional method of * trolling for credentials */
@@ -1024,7 +1027,7 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname,if (err == -EKEYEXPIRED ) downcall_err = -EKEYEXPIRED ;else if (!err) - create_resp =create_auth_rpc_client (clp, &rpc_clnt, &auth, uid, + create_resp =create_auth_rpc_client (clp, tgtname, &rpc_clnt, &auth, uid,AUTHTYPE_KRB5 ,GSS_C_NO_CREDENTIAL ); } }
@@ -1048,7 +1051,7 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname, }for (ccname = credlist; ccname && *ccname; ccname++) {gssd_setup_krb5_machine_gss_ccache (*ccname); -if ((create_auth_rpc_client (clp, &rpc_clnt, +if ((create_auth_rpc_client (clp, tgtname, &rpc_clnt, &auth, uid,AUTHTYPE_KRB5 ,GSS_C_NO_CREDENTIAL )) ==0 ) {
Signature · 1 line
1.8.3.1
Re: [PATCHv2 3/3] gssd: let tgtname override clp->servicename
Quoted 6 lines · J. Bruce Fields
From: "J. Bruce Fields" <[email protected]>
When the kernel provides an explicit "target=" name in the upcall, that should override the name in
clp->servicename.Signed-off-by J. Bruce Fields <[email protected]>
Committed...
steved.
Quoted 64 lines
--- utils/gssd/gssd_proc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)utils/gssd/gssd_proc.c +9
-6@@ -822,6 +822,7 @@ set_port:*/ static int create_auth_rpc_client(struct clnt_info *clp, + char *tgtname, CLIENT **clnt_return, AUTH **auth_return, uid_t uid,@@ -926,14 +927,16 @@ create_auth_rpc_client(struct clnt_info *clp, clnt_spcreateerror(rpc_errmsg)); goto out_fail; } +if (!tgtname) + tgtname = clp->servicename; -printerr (2 ,"creating context with server %s\n" , clp->servicename); - auth =authgss_create_default (rpc_clnt, clp->servicename, &sec); +printerr (2 ,"creating context with server %s\n" , tgtname); + auth =authgss_create_default (rpc_clnt, tgtname, &sec);if (!auth) {/* Our caller should print appropriate message */ printerr (2 ,"WARNING: Failed to create krb5 context for " "user with uid %d for server %s\n" , - uid, clp->servername); + uid, tgtname); goto out_fail; }@@ -1015,7 +1018,7 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname,/* Try first to acquire credentials directly via GSSAPI */ err =gssd_acquire_user_cred (uid, &gss_cred);if (!err) - create_resp =create_auth_rpc_client (clp, &rpc_clnt, &auth, uid, + create_resp =create_auth_rpc_client (clp, tgtname, &rpc_clnt, &auth, uid,AUTHTYPE_KRB5 , gss_cred);/* if create_auth_rplc_client fails try the traditional method of * trolling for credentials */ @@ -1024,7 +1027,7 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname,if (err == -EKEYEXPIRED ) downcall_err = -EKEYEXPIRED ;else if (!err) - create_resp =create_auth_rpc_client (clp, &rpc_clnt, &auth, uid, + create_resp =create_auth_rpc_client (clp, tgtname, &rpc_clnt, &auth, uid,AUTHTYPE_KRB5 ,GSS_C_NO_CREDENTIAL ); } }@@ -1048,7 +1051,7 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname, }for (ccname = credlist; ccname && *ccname; ccname++) {gssd_setup_krb5_machine_gss_ccache (*ccname); -if ((create_auth_rpc_client (clp, &rpc_clnt, +if ((create_auth_rpc_client (clp, tgtname, &rpc_clnt, &auth, uid,AUTHTYPE_KRB5 ,GSS_C_NO_CREDENTIAL )) ==0 ) {
Re: [PATCHv2 1/3] gssd: fix strncmp bug causing client removals
In reply to J. Bruce FieldsQuoted 5 lines · J. Bruce Fields
From: "J. Bruce Fields" <[email protected]>
Both dirname and pdir are null-terminated strings, so there's no reason I can see for the strncmp.
Quoted 7 lines
And this gives the wrong result when comparing the "nfsd" and "
nfsd4_cb" directories! The results were callback clients being removed immediately after creation, when lack of a client with the corresponding name under "nfsd" lead gssd to believe it had disappeared from "nfsd4_cb".Signed-off-by J. Bruce Fields <[email protected]>
Committed...
steved.
Quoted 18 lines
--- utils/gssd/gssd_proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)utils/gssd/gssd_proc.c +1
-1@@ -525,7 +525,7 @@ update_old_clients(struct dirent **namelist, int size, char *pdir)/* only compare entries in the global list that are from the * same pipefs parent directory as "pdir" */ -if (strncmp (clp->dirname, pdir,strlen (pdir)) !=0 )continue ; +if (strcmp (clp->dirname, pdir) !=0 )continue ; stillhere =0 ;for (i=0 ; i < size; i++) {
PATCH 2/3 gssd: don't use tgtname to find our keytab
In reply to J. Bruce FieldsFrom: "J. Bruce Fields" <[email protected]>
The tgtname is of the form service@hostname. It's not a hostname, and attempting to look it up here just causes failure of any upcall with a "target=" field (currently, any upcall on behalf of an nfsv4.0 callback).
I think the theory was that knowning that target= name might help pick the right keytab, but I don't really know if that's helpful. For now, just stop trying to do this.
--- utils/gssd/gssd_proc.c | 3 +-- utils/gssd/krb5_util.c | 10 +++------- utils/gssd/krb5_util.h | 3 +-- 3 files changed, 5 insertions(+), 11 deletions(-)
utils/gssd/gssd_proc.c +1 -2
@@ -1035,8 +1035,7 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname,int success =0 ; do { gssd_refresh_krb5_machine_credential(clp->servername, - NULL, service, - tgtname); + NULL, service); /* * Get a list of credential cache names and try each * of them until one works or we've tried them all
utils/gssd/krb5_util.c +3 -7
@@ -1149,7 +1149,7 @@ gssd_get_krb5_machine_cred_list(char ***list)if (ple->ccname) {/* Make sure cred is up-to-date before returning it */ retval =gssd_refresh_krb5_machine_credential (NULL , ple, -NULL ,NULL ); +NULL );if (retval)continue ;if (i +1 > listsize) {
@@ -1240,8 +1240,7 @@ gssd_destroy_krb5_machine_creds(void)int gssd_refresh_krb5_machine_credential (char *hostname,struct gssd_k5_kt_princ *ple, -char *service, -char *tgtname) +char *service) {krb5_error_code code =0 ;krb5_context context;
@@ -1280,10 +1279,7 @@ gssd_refresh_krb5_machine_credential(char *hostname,if (ple ==NULL ) {krb5_keytab_entry kte; -if (tgtname ==NULL ) - tgtname = hostname; - - code =find_keytab_entry (context, kt, tgtname, &kte, svcnames); + code =find_keytab_entry (context, kt, hostname, &kte, svcnames);if (code) { printerr(0, "ERROR: %s: no usable keytab entry found " "in keytab %s for connection with host %s\n",
utils/gssd/krb5_util.h +1 -2
@@ -31,8 +31,7 @@ void gssd_setup_krb5_machine_gss_ccache(char *servername);void gssd_destroy_krb5_machine_creds (void );int gssd_refresh_krb5_machine_credential (char *hostname,struct gssd_k5_kt_princ *ple, -char *service, -char *tgtname); +char *service);char *gssd_k5_err_msg (krb5_context context,krb5_error_code code);void gssd_k5_get_default_realm (char **def_realm);
Signature · 1 line
1.8.3.1
PATCH 3/3 gssd: let tgtname override clp->servicename
In reply to J. Bruce FieldsFrom: root <[email protected]>
When the kernel provides an explicit "target=" name in the upcall, that should override the name in clp->servicename.
--- utils/gssd/gssd_proc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
utils/gssd/gssd_proc.c +9 -6
@@ -822,6 +822,7 @@ set_port:*/ static int create_auth_rpc_client(struct clnt_info *clp, + char *tgtname, CLIENT **clnt_return, AUTH **auth_return, uid_t uid,
@@ -926,14 +927,16 @@ create_auth_rpc_client(struct clnt_info *clp, clnt_spcreateerror(rpc_errmsg)); goto out_fail; } +if (!tgtname) + tgtname = clp->servicename; -printerr (2 ,"creating context with server %s\n" , clp->servicename); - auth =authgss_create_default (rpc_clnt, clp->servicename, &sec); +printerr (2 ,"creating context with server %s\n" , tgtname); + auth =authgss_create_default (rpc_clnt, tgtname, &sec);if (!auth) {/* Our caller should print appropriate message */ printerr (2 ,"WARNING: Failed to create krb5 context for " "user with uid %d for server %s\n" , - uid, clp->servername); + uid, tgtname); goto out_fail; }
@@ -1015,7 +1018,7 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname,/* Try first to acquire credentials directly via GSSAPI */ err =gssd_acquire_user_cred (uid, &gss_cred);if (!err) - create_resp =create_auth_rpc_client (clp, &rpc_clnt, &auth, uid, + create_resp =create_auth_rpc_client (clp, tgtname, &rpc_clnt, &auth, uid,AUTHTYPE_KRB5 , gss_cred);/* if create_auth_rplc_client fails try the traditional method of * trolling for credentials */
@@ -1024,7 +1027,7 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname,if (err == -EKEYEXPIRED ) downcall_err = -EKEYEXPIRED ;else if (!err) - create_resp =create_auth_rpc_client (clp, &rpc_clnt, &auth, uid, + create_resp =create_auth_rpc_client (clp, tgtname, &rpc_clnt, &auth, uid,AUTHTYPE_KRB5 ,GSS_C_NO_CREDENTIAL ); } }
@@ -1048,7 +1051,7 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname, }for (ccname = credlist; ccname && *ccname; ccname++) {gssd_setup_krb5_machine_gss_ccache (*ccname); -if ((create_auth_rpc_client (clp, &rpc_clnt, +if ((create_auth_rpc_client (clp, tgtname, &rpc_clnt, &auth, uid,AUTHTYPE_KRB5 ,GSS_C_NO_CREDENTIAL )) ==0 ) {
Signature · 1 line
1.8.3.1