mirror of
https://github.com/go-gitea/gitea
synced 2024-11-18 08:04:25 +00:00
6fe756dc93
* Add support for ssh commit signing * Split out ssh verification to separate file * Show ssh key fingerprint on commit page * Update sshsig lib * Make sure we verify against correct namespace * Add ssh public key verification via ssh signatures When adding a public ssh key also validate that this user actually owns the key by signing a token with the private key. * Remove some gpg references and make verify key optional * Fix spaces indentation * Update options/locale/locale_en-US.ini Co-authored-by: Gusted <williamzijl7@hotmail.com> * Update templates/user/settings/keys_ssh.tmpl Co-authored-by: Gusted <williamzijl7@hotmail.com> * Update options/locale/locale_en-US.ini Co-authored-by: Gusted <williamzijl7@hotmail.com> * Update options/locale/locale_en-US.ini Co-authored-by: Gusted <williamzijl7@hotmail.com> * Update models/ssh_key_commit_verification.go Co-authored-by: Gusted <williamzijl7@hotmail.com> * Reword ssh/gpg_key_success message * Change Badsignature to NoKeyFound * Add sign/verify tests * Fix upstream api changes to user_model User * Match exact on SSH signature * Fix code review remarks Co-authored-by: Gusted <williamzijl7@hotmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
62 lines
1.6 KiB
Go
Vendored
62 lines
1.6 KiB
Go
Vendored
// Copyright 2021 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
//go:build (darwin && !ios) || linux
|
|
// +build darwin,!ios linux
|
|
|
|
package unix
|
|
|
|
import (
|
|
"unsafe"
|
|
|
|
"golang.org/x/sys/internal/unsafeheader"
|
|
)
|
|
|
|
// SysvShmAttach attaches the Sysv shared memory segment associated with the
|
|
// shared memory identifier id.
|
|
func SysvShmAttach(id int, addr uintptr, flag int) ([]byte, error) {
|
|
addr, errno := shmat(id, addr, flag)
|
|
if errno != nil {
|
|
return nil, errno
|
|
}
|
|
|
|
// Retrieve the size of the shared memory to enable slice creation
|
|
var info SysvShmDesc
|
|
|
|
_, err := SysvShmCtl(id, IPC_STAT, &info)
|
|
if err != nil {
|
|
// release the shared memory if we can't find the size
|
|
|
|
// ignoring error from shmdt as there's nothing sensible to return here
|
|
shmdt(addr)
|
|
return nil, err
|
|
}
|
|
|
|
// Use unsafe to convert addr into a []byte.
|
|
// TODO: convert to unsafe.Slice once we can assume Go 1.17
|
|
var b []byte
|
|
hdr := (*unsafeheader.Slice)(unsafe.Pointer(&b))
|
|
hdr.Data = unsafe.Pointer(addr)
|
|
hdr.Cap = int(info.Segsz)
|
|
hdr.Len = int(info.Segsz)
|
|
return b, nil
|
|
}
|
|
|
|
// SysvShmDetach unmaps the shared memory slice returned from SysvShmAttach.
|
|
//
|
|
// It is not safe to use the slice after calling this function.
|
|
func SysvShmDetach(data []byte) error {
|
|
if len(data) == 0 {
|
|
return EINVAL
|
|
}
|
|
|
|
return shmdt(uintptr(unsafe.Pointer(&data[0])))
|
|
}
|
|
|
|
// SysvShmGet returns the Sysv shared memory identifier associated with key.
|
|
// If the IPC_CREAT flag is specified a new segment is created.
|
|
func SysvShmGet(key, size, flag int) (id int, err error) {
|
|
return shmget(key, size, flag)
|
|
}
|