Skip to content

Commit a5f534d

Browse files
committed
Update golangci-lint to v2.1.6
1 parent c35be7b commit a5f534d

File tree

7 files changed

+66
-64
lines changed

7 files changed

+66
-64
lines changed

.github/workflows/lint.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ jobs:
99
name: lint
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v3
13-
- uses: actions/setup-go@v4
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-go@v5
1414
with:
15-
go-version: '1.21'
15+
go-version: '1.24'
1616
cache: false
1717
- name: Install PAM
1818
run: |
1919
sudo apt-get update
2020
sudo apt-get install -y libpam-dev
2121
- name: golangci-lint
22-
uses: golangci/golangci-lint-action@v3
22+
uses: golangci/golangci-lint-action@v8
2323
with:
24-
version: v1.54
24+
version: v2.1.6

.golangci.yaml

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
# This is for linting. To run it, please use:
2-
# golangci-lint run ${MODULE}/... [--fix]
3-
1+
version: "2"
42
linters:
5-
# linters to run in addition to default ones
63
enable:
74
- dupl
85
- durationcheck
96
- errname
107
- errorlint
11-
- exportloopref
128
- forbidigo
139
- forcetypeassert
14-
- gci
1510
- godot
16-
- gofmt
1711
- gosec
1812
- misspell
1913
- nakedret
@@ -24,38 +18,44 @@ linters:
2418
- unconvert
2519
- unparam
2620
- whitespace
27-
28-
run:
29-
timeout: 5m
30-
31-
# Get all linter issues, even if duplicated
21+
settings:
22+
forbidigo:
23+
forbid:
24+
- pattern: ioutil\.
25+
- pattern: ^print.*$
26+
nakedret:
27+
max-func-lines: 1
28+
nolintlint:
29+
require-explanation: true
30+
require-specific: true
31+
exclusions:
32+
generated: lax
33+
rules:
34+
- path: (.+)\.go$
35+
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv|w\.Stop). is not checked
36+
- path: (.+)\.go$
37+
text: (G104|G307)
38+
- path: (.+)\.go$
39+
text: Potential file inclusion via variable
40+
- path: (.+)\.go$
41+
text: unused-parameter
42+
- path: (.+)\.go$
43+
text: if-return
44+
paths:
45+
- third_party$
46+
- builtin$
47+
- examples$
3248
issues:
33-
exclude-use-default: false
3449
max-issues-per-linter: 0
3550
max-same-issues: 0
36-
fix: false # we don’t want this in CI
37-
exclude:
38-
# EXC0001 errcheck: most errors are in defer calls, which are safe to ignore and idiomatic Go (would be good to only ignore defer ones though)
39-
- 'Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv|w\.Stop). is not checked'
40-
# EXC0008 gosec: duplicated of errcheck
41-
- (G104|G307)
42-
# EXC0010 gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
43-
- Potential file inclusion via variable
44-
# We want named parameters even if unused, as they help better document the function
45-
- unused-parameter
46-
# Sometimes it is more readable it do a `if err:=a(); err != nil` tha simpy `return a()`
47-
- if-return
48-
49-
nolintlint:
50-
require-explanation: true
51-
require-specific: true
52-
53-
linters-settings:
54-
# Forbid the usage of deprecated ioutil and debug prints
55-
forbidigo:
56-
forbid:
57-
- ioutil\.
58-
- ^print.*$
59-
# Never have naked return ever
60-
nakedret:
61-
max-func-lines: 1
51+
fix: false
52+
formatters:
53+
enable:
54+
- gci
55+
- gofmt
56+
exclusions:
57+
generated: lax
58+
paths:
59+
- third_party$
60+
- builtin$
61+
- examples$

errors.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ package pam
55
*/
66
import "C"
77

8-
// Error is the Type for PAM Return types
8+
// Error represents a PAM error.
99
type Error int
1010

11-
// Pam Return types
11+
// Various errors returned by PAM.
1212
const (
1313
// OpenErr indicates a dlopen() failure when dynamically loading a
1414
// service module.

errors_bsd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package pam
77
*/
88
import "C"
99

10-
// Pam Return types
10+
// Various errors returned by PAM.
1111
const (
1212
// ErrBadItem indicates a bad item passed to pam_*_item().
1313
ErrBadItem Error = C.PAM_BAD_ITEM

errors_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package pam
77
*/
88
import "C"
99

10-
// Pam Return types
10+
// Various errors returned by PAM.
1111
const (
1212
// ErrBadItem indicates a bad item passed to pam_*_item().
1313
ErrBadItem Error = C.PAM_BAD_ITEM

transaction.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ package pam
2121
void init_pam_conv(struct pam_conv *conv, uintptr_t);
2222
2323
typedef 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+
2425
int 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
*/
2627
import "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.
7475
type 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.
154156
func (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.
315317
func (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.
323325
func (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.
330332
func (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.
337339
func (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.
344346
func (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.
351353
func (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) {
401403
var once sync.Once
402404
var 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.
405407
func 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.
413415
func CheckPamHasBinaryProtocol() bool {
414416
return C.BINARY_PROMPT_IS_SUPPORTED != 0
415417
}

transaction_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import "C"
1111
const (
1212
// FailDelay is the app supplied function to override failure delays.
1313
FailDelay Item = C.PAM_FAIL_DELAY
14-
// Xdisplay is the X display name
14+
// Xdisplay is the X display name.
1515
Xdisplay Item = C.PAM_XDISPLAY
1616
// Xauthdata is the X server authentication data.
1717
Xauthdata Item = C.PAM_XAUTHDATA
18-
// AuthtokType is the type for pam_get_authtok
18+
// AuthtokType is the type for pam_get_authtok.
1919
AuthtokType Item = C.PAM_AUTHTOK_TYPE
2020
)

0 commit comments

Comments
 (0)