Repository navigation
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·182 lines (167 loc) · 6.67 KB
File metadata and controls
- Code
- Blame
executable file
·182 lines (167 loc) · 6.67 KB
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
#!/bin/sh
#
# Copyright (c) 2025 Epic Games, Inc. All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY EPIC GAMES, INC. ``AS IS AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EPIC GAMES, INC. OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
set -e
VERSION="0.673"
echo "================================================================================"
echo " Fil-C /opt/fil Distribution"
echo " Version $VERSION"
echo "================================================================================"
echo
echo "Fil-C is a memory-safe implementation of C and C++ that prevents all memory"
echo "safety errors through concurrent garbage collection and invisible capabilities."
echo
echo "This distribution includes:"
echo " - Fil-C compiler version $VERSION (filcc, fil++) and its runtime (libpizlo.so)"
echo " - Basic libraries compiled with Fil-C (glibc 2.40, LLVM libc++ 20.1.8)"
echo " - Memory safe programs compiled with Fil-C:"
echo " - GNU Bash - Compression utilities"
echo " - GNU Coreutils - OpenSSL cryptographic library"
echo " - GNU Binutils - OpenSSH client and server"
echo " - Mg text editor - pkgconf"
echo
echo "********************************************************************************"
echo " WARNING!"
echo "********************************************************************************"
echo "THIS IS THE FIRST RELEASE of the /opt/fil binary distribution! Take appropriate"
echo "precautions before using! This distribution is still under active development!"
echo
echo "THIS SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND."
echo "********************************************************************************"
echo
if [ `id -u` -ne 0 ]; then
echo "ERROR: This installer must be run as root (use sudo or run as root user)."
exit 1
fi
if [ -e /opt/fil ]; then
echo "ERROR: /opt/fil already exists!"
echo "Please remove or move it before running this installer:"
echo " rm -rf /opt/fil"
echo " or"
echo " mv /opt/fil /opt/fil.backup"
exit 1
fi
echo "This installer will:"
if [ ! -d /opt ]; then
echo " - Create /opt directory (doesn't currently exist)"
fi
echo " - Extract fil.tar to /opt, creating /opt/fil"
echo
echo "Type YES (in all caps) to proceed with installation, or anything else to abort:"
read response
if [ "$response" != "YES" ]; then
echo "Installation aborted."
exit 1
fi
echo
echo "Extracting fil.tar to /opt..."
if [ ! -f fil.tar ]; then
echo "Error: fil.tar not found in current directory"
exit 1
fi
if [ ! -d /opt ]; then
echo "Creating /opt directory..."
mkdir -p /opt
fi
cd /opt
tar -xf "$OLDPWD/fil.tar"
echo
echo "Setting up SSH host keys..."
# Check if SSH host keys exist in /etc/ssh
if [ -f /etc/ssh/ssh_host_rsa_key ] \
&& [ -f /etc/ssh/ssh_host_ecdsa_key ] \
&& [ -f /etc/ssh/ssh_host_ed25519_key ] \
&& [ -f /etc/ssh/ssh_host_rsa_key.pub ] \
&& [ -f /etc/ssh/ssh_host_ecdsa_key.pub ] \
&& [ -f /etc/ssh/ssh_host_ed25519_key.pub ]; then
echo "Found existing SSH host keys in /etc/ssh"
echo "Copying them to /opt/fil/etc/ssh..."
cp -v /etc/ssh/ssh_host_rsa_key /opt/fil/etc/ssh/
cp -v /etc/ssh/ssh_host_ecdsa_key /opt/fil/etc/ssh/
cp -v /etc/ssh/ssh_host_ed25519_key /opt/fil/etc/ssh/
cp -v /etc/ssh/ssh_host_rsa_key.pub /opt/fil/etc/ssh/
cp -v /etc/ssh/ssh_host_ecdsa_key.pub /opt/fil/etc/ssh/
cp -v /etc/ssh/ssh_host_ed25519_key.pub /opt/fil/etc/ssh/
chmod -v 600 /opt/fil/etc/ssh/ssh_host_rsa_key
chmod -v 600 /opt/fil/etc/ssh/ssh_host_ecdsa_key
chmod -v 600 /opt/fil/etc/ssh/ssh_host_ed25519_key
chmod -v 644 /opt/fil/etc/ssh/ssh_host_rsa_key.pub
chmod -v 644 /opt/fil/etc/ssh/ssh_host_ecdsa_key.pub
chmod -v 644 /opt/fil/etc/ssh/ssh_host_ed25519_key.pub
echo "SSH host keys copied successfully."
else
echo "No existing SSH host keys found in /etc/ssh"
echo "Generating new SSH host keys for /opt/fil..."
/opt/fil/bin/ssh-keygen -A
echo "New SSH host keys generated."
fi
if id sshd > /dev/null 2>&1; then
echo "SSH privsep user sshd already exists."
else
echo
if getent group sshd > /dev/null 2>&1; then
echo "SSH privsep user sshd does not exist!"
echo
echo "To create sshd privsep user, type YES (in all caps) or anything else to skip."
else
echo "SSH privsep user sshd and group sshd do not exist!"
echo
echo "To create sshd privsep user and sshd group, type YES (in all caps) or anything"
echo "else to skip."
fi
read sshd_response
if [ "$sshd_response" = "YES" ]; then
if ! getent group sshd > /dev/null 2>&1; then
groupadd sshd
echo "Created sshd group."
fi
useradd -c 'sshd PrivSep' \
-d /opt/fil/var/lib/sshd \
-g sshd \
-s /bin/false \
sshd
echo "Created sshd privsep user."
else
echo "Not creating sshd privsep user."
fi
fi
echo
echo "================================================================================"
echo " Installation Complete!"
echo "================================================================================"
echo
echo "To use Fil-C, add /opt/fil/bin to your PATH:"
echo " export PATH=/opt/fil/bin:\$PATH"
echo
echo "You can use the memory-safe OpenSSH server at:"
echo " /opt/fil/sbin/sshd"
echo
echo "To compile C programs with Fil-C:"
echo " filcc -o program program.c -g -O"
echo
echo "To compile C++ programs with Fil-C++:"
echo " fil++ -o program program.cpp -g -O -std=c++20"
echo
echo "For more information, see README.md in the distribution directory."
echo