Skip to content

x/sys/unix: unix.Klogctl does not allow access to len arg #34672

@hugelgupf

Description

@hugelgupf

Linux sys_syslog looks like this:

int syslog(int type, char *buf, int len);

In Go's x/sys/unix, it's this

func Klogctl(typ int, buf []byte) (n int, err error)
// = syslog(typ, buf, len(buf))

That's kinda lame, because the len arg is not only used for the length, as you can see in the man page:

SYSLOG_ACTION_CONSOLE_LEVEL (8)
              The call sets console_loglevel to the value given in len,
              which must be an integer between 1 and 8 (inclusive).  The
              kernel silently enforces a minimum value of
              minimum_console_loglevel for len.  See the log level section
              for details.  The bufp argument is ignored.

So now you, either you gotta construct the unix.Syscall yourself or trick Klogctl into passing the right length:

unix.Klogctl(8, []byte{1, 2}) // Set console level 2!
// Yah ok this is silly

Perhaps there should be another function like this?

func Klogset(typ int, arg int) error
// = syslog(typ, nullptr, arg)

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.OS-Linux

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions