summaryrefslogtreecommitdiffstats
path: root/cmd/serv.go
blob: 7c2be5157ad1fbf009198157f10c9e5a94374cd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
// Copyright 2014 The Gogs Authors. All rights reserved.
// Copyright 2016 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package cmd

import (
	"encoding/json"
	"fmt"
	"net/http"
	"net/url"
	"os"
	"os/exec"
	"regexp"
	"strconv"
	"strings"
	"time"

	"code.gitea.io/gitea/models"
	"code.gitea.io/gitea/modules/lfs"
	"code.gitea.io/gitea/modules/log"
	"code.gitea.io/gitea/modules/pprof"
	"code.gitea.io/gitea/modules/private"
	"code.gitea.io/gitea/modules/setting"

	"github.com/dgrijalva/jwt-go"
	"github.com/unknwon/com"
	"github.com/urfave/cli"
)

const (
	lfsAuthenticateVerb = "git-lfs-authenticate"
)

// CmdServ represents the available serv sub-command.
var CmdServ = cli.Command{
	Name:        "serv",
	Usage:       "This command should only be called by SSH shell",
	Description: `Serv provide access auth for repositories`,
	Action:      runServ,
	Flags: []cli.Flag{
		cli.BoolFlag{
			Name: "enable-pprof",
		},
		cli.BoolFlag{
			Name: "debug",
		},
	},
}

func setup(logPath string, debug bool) {
	if !debug {
		_ = log.DelLogger("console")
	}
	setting.NewContext()
	if debug {
		setting.ProdMode = false
	}
}

func parseCmd(cmd string) (string, string) {
	ss := strings.SplitN(cmd, " ", 2)
	if len(ss) != 2 {
		return "", ""
	}
	return ss[0], strings.Replace(ss[1], "'/", "'", 1)
}

var (
	allowedCommands = map[string]models.AccessMode{
		"git-upload-pack":    models.AccessModeRead,
		"git-upload-archive": models.AccessModeRead,
		"git-receive-pack":   models.AccessModeWrite,
		lfsAuthenticateVerb:  models.AccessModeNone,
	}
	alphaDashDotPattern = regexp.MustCompile(`[^\w-\.]`)
)

func fail(userMessage, logMessage string, args ...interface{}) {
	fmt.Fprintln(os.Stderr, "Gitea:", userMessage)

	if len(logMessage) > 0 {
		if !setting.ProdMode {
			fmt.Fprintf(os.Stderr, logMessage+"\n", args...)
		}
	}

	os.Exit(1)
}

func runServ(c *cli.Context) error {
	// FIXME: This needs to internationalised
	setup("serv.log", c.Bool("debug"))

	if setting.SSH.Disabled {
		println("Gitea: SSH has been disabled")
		return nil
	}

	if len(c.Args()) < 1 {
		if err := cli.ShowSubcommandHelp(c); err != nil {
			fmt.Printf("error showing subcommand help: %v\n", err)
		}
		return nil
	}

	keys := strings.Split(c.Args()[0], "-")
	if len(keys) != 2 || keys[0] != "key" {
		fail("Key ID format error", "Invalid key argument: %s", c.Args()[0])
	}
	keyID := com.StrTo(keys[1]).MustInt64()

	cmd := os.Getenv("SSH_ORIGINAL_COMMAND")
	if len(cmd) == 0 {
		key, user, err := private.ServNoCommand(keyID)
		if err != nil {
			fail("Internal error", "Failed to check provided key: %v", err)
		}
		if key.Type == models.KeyTypeDeploy {
			println("Hi there! You've successfully authenticated with the deploy key named " + key.Name + ", but Gitea does not provide shell access.")
		} else {
			println("Hi there, " + user.Name + "! You've successfully authenticated with the key named " + key.Name + ", but Gitea does not provide shell access.")
		}
		println("If this is unexpected, please log in with password and setup Gitea under another user.")
		return nil
	}

	verb, args := parseCmd(cmd)

	var lfsVerb string
	if verb == lfsAuthenticateVerb {
		if !setting.LFS.StartServer {
			fail("Unknown git command", "LFS authentication request over SSH denied, LFS support is disabled")
		}

		argsSplit := strings.Split(args, " ")
		if len(argsSplit) >= 2 {
			args = strings.TrimSpace(argsSplit[0])
			lfsVerb = strings.TrimSpace(argsSplit[1])
		}
	}

	repoPath := strings.ToLower(strings.Trim(args, "'"))
	rr := strings.SplitN(repoPath, "/", 2)
	if len(rr) != 2 {
		fail("Invalid repository path", "Invalid repository path: %v", args)
	}

	username := strings.ToLower(rr[0])
	reponame := strings.ToLower(strings.TrimSuffix(rr[1], ".git"))

	if alphaDashDotPattern.MatchString(reponame) {
		fail("Invalid repo name", "Invalid repo name: %s", reponame)
	}

	if setting.EnablePprof || c.Bool("enable-pprof") {
		if err := os.MkdirAll(setting.PprofDataPath, os.ModePerm); err != nil {
			fail("Error while trying to create PPROF_DATA_PATH", "Error while trying to create PPROF_DATA_PATH: %v", err)
		}

		stopCPUProfiler, err := pprof.DumpCPUProfileForUsername(setting.PprofDataPath, username)
		if err != nil {
			fail("Internal Server Error", "Unable to start CPU profile: %v", err)
		}
		defer func() {
			stopCPUProfiler()
			err := pprof.DumpMemProfileForUsername(setting.PprofDataPath, username)
			if err != nil {
				fail("Internal Server Error", "Unable to dump Mem Profile: %v", err)
			}
		}()
	}

	requestedMode, has := allowedCommands[verb]
	if !has {
		fail("Unknown git command", "Unknown git command %s", verb)
	}

	if verb == lfsAuthenticateVerb {
		if lfsVerb == "upload" {
			requestedMode = models.AccessModeWrite
		} else if lfsVerb == "download" {
			requestedMode = models.AccessModeRead
		} else {
			fail("Unknown LFS verb", "Unknown lfs verb %s", lfsVerb)
		}
	}

	results, err := private.ServCommand(keyID, username, reponame, requestedMode, verb, lfsVerb)
	if err != nil {
		if private.IsErrServCommand(err) {
			errServCommand := err.(private.ErrServCommand)
			if errServCommand.StatusCode != http.StatusInternalServerError {
				fail("Unauthorized", "%s", errServCommand.Error())
			} else {
				fail("Internal Server Error", "%s", errServCommand.Error())
			}
		}
		fail("Internal Server Error", "%s", err.Error())
	}
	os.Setenv(models.EnvRepoIsWiki, strconv.FormatBool(results.IsWiki))
	os.Setenv(models.EnvRepoName, results.RepoName)
	os.Setenv(models.EnvRepoUsername, results.OwnerName)
	os.Setenv(models.EnvPusherName, results.UserName)
	os.Setenv(models.EnvPusherID, strconv.FormatInt(results.UserID, 10))
	os.Setenv(models.ProtectedBranchRepoID, strconv.FormatInt(results.RepoID, 10))
	os.Setenv(models.ProtectedBranchPRID, fmt.Sprintf("%d", 0))
	os.Setenv(models.EnvIsDeployKey, fmt.Sprintf("%t", results.IsDeployKey))
	os.Setenv(models.EnvKeyID, fmt.Sprintf("%d", results.KeyID))

	//LFS token authentication
	if verb == lfsAuthenticateVerb {
		url := fmt.Sprintf("%s%s/%s.git/info/lfs", setting.AppURL, url.PathEscape(results.OwnerName), url.PathEscape(results.RepoName))

		now := time.Now()
		claims := lfs.Claims{
			StandardClaims: jwt.StandardClaims{
				ExpiresAt: now.Add(setting.LFS.HTTPAuthExpiry).Unix(),
				NotBefore: now.Unix(),
			},
			RepoID: results.RepoID,
			Op:     lfsVerb,
			UserID: results.UserID,
		}
		token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)

		// Sign and get the complete encoded token as a string using the secret
		tokenString, err := token.SignedString(setting.LFS.JWTSecretBytes)
		if err != nil {
			fail("Internal error", "Failed to sign JWT token: %v", err)
		}

		tokenAuthentication := &models.LFSTokenResponse{
			Header: make(map[string]string),
			Href:   url,
		}
		tokenAuthentication.Header["Authorization"] = fmt.Sprintf("Bearer %s", tokenString)

		enc := json.NewEncoder(os.Stdout)
		err = enc.Encode(tokenAuthentication)
		if err != nil {
			fail("Internal error", "Failed to encode LFS json response: %v", err)
		}
		return nil
	}

	// Special handle for Windows.
	if setting.IsWindows {
		verb = strings.Replace(verb, "-", " ", 1)
	}

	var gitcmd *exec.Cmd
	verbs := strings.Split(verb, " ")
	if len(verbs) == 2 {
		gitcmd = exec.Command(verbs[0], verbs[1], repoPath)
	} else {
		gitcmd = exec.Command(verb, repoPath)
	}

	gitcmd.Dir = setting.RepoRootPath
	gitcmd.Stdout = os.Stdout
	gitcmd.Stdin = os.Stdin
	gitcmd.Stderr = os.Stderr
	if err = gitcmd.Run(); err != nil {
		fail("Internal error", "Failed to execute git command: %v", err)
	}

	// Update user key activity.
	if results.KeyID > 0 {
		if err = private.UpdatePublicKeyInRepo(results.KeyID, results.RepoID); err != nil {
			fail("Internal error", "UpdatePublicKeyInRepo: %v", err)
		}
	}

	return nil
}
y Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
path: root/l10n/eu/settings.po
blob: 89f2191352d072dc7cc57f710d3932bfad69a397 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# 
# Translators:
#   <asieriko@gmail.com>, 2012.
# Asier Urio Larrea <asieriko@gmail.com>, 2011.
# Piarres Beobide <pi@beobide.net>, 2012.
msgid ""
msgstr ""
"Project-Id-Version: ownCloud\n"
"Report-Msgid-Bugs-To: http://bugs.owncloud.org/\n"
"POT-Creation-Date: 2012-08-05 19:00+0200\n"
"PO-Revision-Date: 2012-08-05 17:01+0000\n"
"Last-Translator: owncloud_robot <thomas.mueller@tmit.eu>\n"
"Language-Team: Basque (http://www.transifex.com/projects/p/owncloud/language/eu/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: eu\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"

#: ajax/apps/ocs.php:23
msgid "Unable to load list from App Store"
msgstr ""

#: ajax/lostpassword.php:14
msgid "Email saved"
msgstr "Eposta gorde da"

#: ajax/lostpassword.php:16
msgid "Invalid email"
msgstr "Baliogabeko eposta"

#: ajax/openid.php:16
msgid "OpenID Changed"
msgstr "OpenID aldatuta"

#: ajax/openid.php:18 ajax/setlanguage.php:20 ajax/setlanguage.php:23
msgid "Invalid request"
msgstr "Baliogabeko eskaria"

#: ajax/removeuser.php:13 ajax/setquota.php:18 ajax/togglegroups.php:18
msgid "Authentication error"
msgstr "Autentifikazio errorea"

#: ajax/setlanguage.php:18
msgid "Language changed"
msgstr "Hizkuntza aldatuta"

#: js/apps.js:18
msgid "Error"
msgstr ""

#: js/apps.js:39 js/apps.js:73
msgid "Disable"
msgstr "Ez-gaitu"

#: js/apps.js:39 js/apps.js:62
msgid "Enable"
msgstr "Gaitu"

#: js/personal.js:69
msgid "Saving..."
msgstr "Gordetzen..."

#: personal.php:46 personal.php:47
msgid "__language_name__"
msgstr "Euskera"

#: templates/admin.php:14
msgid "Security Warning"
msgstr "Segurtasun abisua"

#: templates/admin.php:28
msgid "Log"
msgstr "Egunkaria"

#: templates/admin.php:56
msgid "More"
msgstr "Gehiago"

#: templates/apps.php:10
msgid "Add your App"
msgstr "Gehitu zure aplikazioa"

#: templates/apps.php:26
msgid "Select an App"
msgstr "Aukeratu programa bat"

#: templates/apps.php:29
msgid "See application page at apps.owncloud.com"
msgstr "Ikusi programen orria apps.owncloud.com en"

#: templates/apps.php:30
msgid "-licensed"
msgstr "lizentziarekin"

#: templates/apps.php:30
msgid "by"
msgstr " Egilea:"

#: templates/help.php:8
msgid "Documentation"
msgstr "Dokumentazioa"

#: templates/help.php:9
msgid "Managing Big Files"
msgstr "Fitxategi handien kudeaketa"

#: templates/help.php:10
msgid "Ask a question"
msgstr "Egin galdera bat"

#: templates/help.php:22
msgid "Problems connecting to help database."
msgstr "Arazoak daude laguntza datubasera konektatzeko."

#: templates/help.php:23
msgid "Go there manually."
msgstr "Joan hara eskuz."

#: templates/help.php:31
msgid "Answer"
msgstr "Erantzun"

#: templates/personal.php:8
msgid "You use"
msgstr "Erabiltzen ari zara "

#: templates/personal.php:8
msgid "of the available"
msgstr "eta guztira erabil dezakezu "

#: templates/personal.php:12
msgid "Desktop and Mobile Syncing Clients"
msgstr "Mahaigain eta mugikorren sinkronizazio bezeroak"

#: templates/personal.php:13
msgid "Download"
msgstr "Deskargatu"

#: templates/personal.php:19
msgid "Your password got changed"
msgstr "Zure pasahitza aldatu da"

#: templates/personal.php:20
msgid "Unable to change your password"
msgstr "Ezin izan da zure pasahitza aldatu"

#: templates/personal.php:21
msgid "Current password"
msgstr "Uneko pasahitza"

#: templates/personal.php:22
msgid "New password"
msgstr "Pasahitz berria"

#: templates/personal.php:23
msgid "show"
msgstr "erakutsi"

#: templates/personal.php:24
msgid "Change password"
msgstr "Aldatu pasahitza"

#: templates/personal.php:30
msgid "Email"
msgstr "E-Posta"

#: templates/personal.php:31
msgid "Your email address"
msgstr "Zure e-posta"

#: templates/personal.php:32
msgid "Fill in an email address to enable password recovery"
msgstr "Idatz ezazu e-posta bat pasahitza berreskuratu ahal izateko"

#: templates/personal.php:38 templates/personal.php:39
msgid "Language"
msgstr "Hizkuntza"

#: templates/personal.php:44
msgid "Help translate"
msgstr "Lagundu itzultzen"

#: templates/personal.php:51
msgid "use this address to connect to your ownCloud in your file manager"
msgstr "erabili helbide hau zure fitxategi kudeatzailean zure ownCloudera konektatzeko"

#: templates/users.php:21 templates/users.php:76
msgid "Name"
msgstr "Izena"

#: templates/users.php:23 templates/users.php:77
msgid "Password"
msgstr "Pasahitza"

#: templates/users.php:26 templates/users.php:78 templates/users.php:98
msgid "Groups"
msgstr "Taldeak"

#: templates/users.php:32
msgid "Create"
msgstr "Sortu"

#: templates/users.php:35
msgid "Default Quota"
msgstr "Kuota lehentsia"

#: templates/users.php:55 templates/users.php:138
msgid "Other"
msgstr "Besteak"

#: templates/users.php:80 templates/users.php:112
msgid "SubAdmin"
msgstr "SubAdmin"

#: templates/users.php:82
msgid "Quota"
msgstr "Kuota"

#: templates/users.php:146
msgid "Delete"
msgstr "Ezabatu"