@@ -21,6 +21,7 @@ package pam
2121void init_pam_conv(struct pam_conv *conv, uintptr_t); 
2222
2323typedef int (*pam_start_confdir_fn)(const char *service_name, const char *user, const struct pam_conv *pam_conversation, const char *confdir, pam_handle_t **pamh); 
24+ 
2425int pam_start_confdir_wrapper(pam_start_confdir_fn fn, const char *service_name, const char *user, const struct pam_conv *pam_conversation, const char *confdir, pam_handle_t **pamh); 
2526*/ 
2627import  "C" 
@@ -54,8 +55,8 @@ const (
5455	// TextInfo indicates the conversation handler should display some 
5556	// text. 
5657	TextInfo  Style  =  C .PAM_TEXT_INFO 
57- 	// BinaryPrompt indicates the conversation handler that should implement  
58- 	// the private binary protocol 
58+ 	// BinaryPrompt indicates the conversation handler that should 
59+ 	// implement  the private binary protocol.  
5960	BinaryPrompt  Style  =  C .PAM_BINARY_PROMPT 
6061)
6162
@@ -68,9 +69,9 @@ type ConversationHandler interface {
6869	RespondPAM (Style , string ) (string , error )
6970}
7071
71- // BinaryPointer exposes the type used for the data in a binary conversation 
72- // it  represents a pointer to data that is produced by the module and that  
73- // must be  parsed depending on the protocol in use 
72+ // BinaryPointer exposes the type used for the data in a binary conversation.  
73+ // It  represents a pointer to data that is produced by the module and must be  
74+ // parsed depending on the protocol in use.  
7475type  BinaryPointer  unsafe.Pointer 
7576
7677// BinaryConversationHandler is an interface for objects that can be used as 
@@ -150,7 +151,8 @@ func (t *Transaction) End() error {
150151		C .int (t .lastStatus .Load ())))
151152}
152153
153- // Allows to call pam functions managing return status 
154+ // handlePamStatus stores the last error returned by PAM and converts it to a 
155+ // Go error. 
154156func  (t  * Transaction ) handlePamStatus (cStatus  C.int ) error  {
155157	t .lastStatus .Store (int32 (cStatus ))
156158	if  status  :=  Error (cStatus ); status  !=  success  {
@@ -311,43 +313,43 @@ const (
311313
312314// Authenticate is used to authenticate the user. 
313315// 
314- // Valid flags: Silent, DisallowNullAuthtok 
316+ // Valid flags: Silent, DisallowNullAuthtok.  
315317func  (t  * Transaction ) Authenticate (f  Flags ) error  {
316318	return  t .handlePamStatus (C .pam_authenticate (t .handle , C .int (f )))
317319}
318320
319321// SetCred is used to establish, maintain and delete the credentials of a 
320322// user. 
321323// 
322- // Valid flags: EstablishCred, DeleteCred, ReinitializeCred, RefreshCred 
324+ // Valid flags: EstablishCred, DeleteCred, ReinitializeCred, RefreshCred.  
323325func  (t  * Transaction ) SetCred (f  Flags ) error  {
324326	return  t .handlePamStatus (C .pam_setcred (t .handle , C .int (f )))
325327}
326328
327329// AcctMgmt is used to determine if the user's account is valid. 
328330// 
329- // Valid flags: Silent, DisallowNullAuthtok 
331+ // Valid flags: Silent, DisallowNullAuthtok.  
330332func  (t  * Transaction ) AcctMgmt (f  Flags ) error  {
331333	return  t .handlePamStatus (C .pam_acct_mgmt (t .handle , C .int (f )))
332334}
333335
334336// ChangeAuthTok is used to change the authentication token. 
335337// 
336- // Valid flags: Silent, ChangeExpiredAuthtok 
338+ // Valid flags: Silent, ChangeExpiredAuthtok.  
337339func  (t  * Transaction ) ChangeAuthTok (f  Flags ) error  {
338340	return  t .handlePamStatus (C .pam_chauthtok (t .handle , C .int (f )))
339341}
340342
341343// OpenSession sets up a user session for an authenticated user. 
342344// 
343- // Valid flags: Slient  
345+ // Valid flags: Silent.  
344346func  (t  * Transaction ) OpenSession (f  Flags ) error  {
345347	return  t .handlePamStatus (C .pam_open_session (t .handle , C .int (f )))
346348}
347349
348350// CloseSession closes a previously opened session. 
349351// 
350- // Valid flags: Silent 
352+ // Valid flags: Silent.  
351353func  (t  * Transaction ) CloseSession (f  Flags ) error  {
352354	return  t .handlePamStatus (C .pam_close_session (t .handle , C .int (f )))
353355}
@@ -401,15 +403,15 @@ func (t *Transaction) GetEnvList() (map[string]string, error) {
401403var  once  sync.Once 
402404var  pamStartConfdirPtr  C.pam_start_confdir_fn 
403405
404- // CheckPamHasStartConfdir return if pam on system  supports pam_system_confdir 
406+ // CheckPamHasStartConfdir reports whether PAM  supports pam_system_confdir.  
405407func  CheckPamHasStartConfdir () bool  {
406408	once .Do (func () {
407409		pamStartConfdirPtr  =  C .pam_start_confdir_fn (C .dlsym (C .RTLD_NEXT , C .CString ("pam_start_confdir" )))
408410	})
409411	return  pamStartConfdirPtr  !=  nil 
410412}
411413
412- // CheckPamHasBinaryProtocol return if pam on system  supports PAM_BINARY_PROMPT 
414+ // CheckPamHasBinaryProtocol reports whether PAM  supports PAM_BINARY_PROMPT.  
413415func  CheckPamHasBinaryProtocol () bool  {
414416	return  C .BINARY_PROMPT_IS_SUPPORTED  !=  0 
415417}
0 commit comments