Skip to content

On OpenBSD os.ModeSticky does not work as non-root user #22615

@mtzanidakis

Description

@mtzanidakis

What version of Go are you using (go version)?

go version go1.9.2 openbsd/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

OpenBSD 6.2-current (2017110) amd64

What did you do?

The following code:

package main

import (
	"fmt"
	"io/ioutil"
	"os"
)

func main() {
	ioutil.WriteFile("./test.txt", []byte("test\n"), 0755|os.ModeSticky)
	fi, _ := os.Lstat("./test.txt")
	fmt.Printf("mode: %v\n", fi.Mode())
}

What did you expect to see?

When run as non-root user it should return:
mode: trwxr-xr-x

like it does on Linux.

What did you see instead?

On OpenBSD, if it's run by root it returns:
mode: trwxr-xr-x

If it's run by a non-root user it returns:
mode: -rwxr-xr-x

os.Lstat works correctly in all cases; these are the actual file permissions.

(found it accidentally by running the tests for restic.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions