403Webshell
Server IP : 147.79.69.71  /  Your IP : 216.73.217.88
Web Server : LiteSpeed
System : Linux in-mum-web1677.main-hosting.eu 5.14.0-611.55.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 19 15:19:29 EDT 2026 x86_64
User : u635632881 ( 635632881)
PHP Version : 8.2.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/golang/1.22.0/src/cmd/gofmt/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/golang/1.22.0/src/cmd/gofmt/gofmt_unix_test.go
// Copyright 2023 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 unix

package main

import (
	"os"
	"path/filepath"
	"strings"
	"testing"
	"time"
)

func TestPermissions(t *testing.T) {
	if os.Getuid() == 0 {
		t.Skip("skipping permission test when running as root")
	}

	dir := t.TempDir()
	fn := filepath.Join(dir, "perm.go")

	// Create a file that needs formatting without write permission.
	if err := os.WriteFile(filepath.Join(fn), []byte("  package main"), 0o400); err != nil {
		t.Fatal(err)
	}

	// Set mtime of the file in the past.
	past := time.Now().Add(-time.Hour)
	if err := os.Chtimes(fn, past, past); err != nil {
		t.Fatal(err)
	}

	info, err := os.Stat(fn)
	if err != nil {
		t.Fatal(err)
	}

	defer func() { *write = false }()
	*write = true

	initParserMode()
	initRewrite()

	const maxWeight = 2 << 20
	var buf, errBuf strings.Builder
	s := newSequencer(maxWeight, &buf, &errBuf)
	s.Add(fileWeight(fn, info), func(r *reporter) error {
		return processFile(fn, info, nil, r)
	})
	if s.GetExitCode() == 0 {
		t.Fatal("rewrite of read-only file succeeded unexpectedly")
	}
	if errBuf.Len() > 0 {
		t.Log(errBuf)
	}

	info, err = os.Stat(fn)
	if err != nil {
		t.Fatal(err)
	}
	if !info.ModTime().Equal(past) {
		t.Errorf("after rewrite mod time is %v, want %v", info.ModTime(), past)
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit