Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Curve
Commits
01a66899
Commit
01a66899
authored
3 years ago
by
Hanqing Wu
Committed by
ilixiaocui
3 years ago
Browse files
Options
Download
Email Patches
Plain Diff
scripts: fix potential overflow when cnovert ip to value
parent
87da7ce4
master
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
curve-ansible/roles/install_package/templates/chunkserver_ctl.sh.j2
+9
-2
...ble/roles/install_package/templates/chunkserver_ctl.sh.j2
curve-ansible/roles/install_package/templates/mds-daemon.sh.j2
+9
-2
...-ansible/roles/install_package/templates/mds-daemon.sh.j2
curve-ansible/roles/install_package/templates/snapshot-daemon.sh.j2
+9
-2
...ble/roles/install_package/templates/snapshot-daemon.sh.j2
with
27 additions
and
6 deletions
+27
-6
curve-ansible/roles/install_package/templates/chunkserver_ctl.sh.j2
+
9
-
2
View file @
01a66899
...
...
@@ -43,10 +43,17 @@ function help() {
echo
" [-nc|--noConfirm] if specified, deploy no need to confirm"
}
function
ip_value
()
{
echo
$1
|
awk
-F
'[:/.]'
'{
mask = (2 ^ 8)
printf ("%.0f", (($1 * mask + $2) * mask + $3) * mask + $4)
}'
}
# 从subnet获取ip
function
get_ip_from_subnet
()
{
subnet
=
$1
prefix
=
`
echo
$subnet
|awk
-F
/
'{print $1}'
|awk
-F
.
'{printf "%d", ($1*(2^24))+($2*(2^16))+($3*(2^8))+$4}'
`
prefix
=
$(
ip_value
$subnet
)
mod
=
`
echo
$subnet
|awk
-F
/
'{print $2}'
`
mask
=
$((
2
**
32
-
2
**(
32
-
$mod
))
)
# 对prefix再取一次模,为了支持10.182.26.50/22这种格式
...
...
@@ -55,7 +62,7 @@ function get_ip_from_subnet() {
for
i
in
`
/sbin/ifconfig
-a
|grep inet|grep
-v
inet6|awk
'{print $2}'
|tr
-d
"addr:"
`
do
# 把ip转换成整数
ip_int
=
`
echo
$i
|awk
-F
.
'{printf "%d\n", ($1*(2^24))+($2*(2^16))+($3*(2^8))+$4}'
`
ip_int
=
$(
ip_value
$i
)
if
[
$((
$ip_int
&
$mask
))
-eq
$prefix
]
then
ip
=
$i
...
...
This diff is collapsed.
Click to expand it.
curve-ansible/roles/install_package/templates/mds-daemon.sh.j2
+
9
-
2
View file @
01a66899
...
...
@@ -21,6 +21,13 @@ daemonLog=${logPath}/curve-mds-daemon.log
# console output
consoleLog
=
${
logPath
}
/curve-mds-console.log
function
ip_value
()
{
echo
$1
|
awk
-F
'[:/.]'
'{
mask = (2 ^ 8)
printf ("%.0f", (($1 * mask + $2) * mask + $3) * mask + $4)
}'
}
# 启动mds
function
start_mds
()
{
# 检查daemon
...
...
@@ -88,7 +95,7 @@ function start_mds() {
then
subnet
=
`
cat
$confPath
|grep global.subnet|awk
-F
"="
'{print $2}'
`
port
=
`
cat
$confPath
|grep global.port|awk
-F
"="
'{print $2}'
`
prefix
=
`
echo
$subnet
|awk
-F
/
'{print $1}'
|awk
-F
.
'{printf "%d", ($1*(2^24))+($2*(2^16))+($3*(2^8))+$4}'
`
prefix
=
$(
ip_value
$subnet
)
mod
=
`
echo
$subnet
|awk
-F
/
'{print $2}'
`
mask
=
$((
2
**
32
-
2
**(
32
-
$mod
))
)
ip
=
...
...
@@ -99,7 +106,7 @@ function start_mds() {
for
i
in
`
/sbin/ifconfig
-a
|grep inet|grep
-v
inet6|awk
'{print $2}'
|tr
-d
"addr:"
`
do
# 把ip转换成整数
ip_int
=
`
echo
$i
|awk
-F
.
'{printf "%d\n", ($1*(2^24))+($2*(2^16))+($3*(2^8))+$4}'
`
ip_int
=
$(
ip_value
$i
)
if
[
$((
$ip_int
&
$mask
))
-eq
$prefix
]
then
ip
=
$i
...
...
This diff is collapsed.
Click to expand it.
curve-ansible/roles/install_package/templates/snapshot-daemon.sh.j2
+
9
-
2
View file @
01a66899
...
...
@@ -21,6 +21,13 @@ daemonLog=${logPath}/curve-snapshot-daemon.log
# console output
consoleLog
=
${
logPath
}
/curve-snapshot-console.log
function
ip_value
()
{
echo
$1
|
awk
-F
'[:/.]'
'{
mask = (2 ^ 8)
printf ("%.0f", (($1 * mask + $2) * mask + $3) * mask + $4)
}'
}
# 启动snapshotcloneserver
function
start_server
()
{
# 检查daemon
...
...
@@ -88,7 +95,7 @@ function start_server() {
then
subnet
=
`
cat
$confPath
|grep server.subnet|awk
-F
"="
'{print $2}'
`
port
=
`
cat
$confPath
|grep server.port|awk
-F
"="
'{print $2}'
`
prefix
=
`
echo
$subnet
|awk
-F
/
'{print $1}'
|awk
-F
.
'{printf "%d", ($1*(2^24))+($2*(2^16))+($3*(2^8))+$4}'
`
prefix
=
$(
ip_value
$subnet
)
mod
=
`
echo
$subnet
|awk
-F
/
'{print $2}'
`
mask
=
$((
2
**
32
-
2
**(
32
-
$mod
))
)
ip
=
...
...
@@ -99,7 +106,7 @@ function start_server() {
for
i
in
`
/sbin/ifconfig
-a
|grep inet|grep
-v
inet6|awk
'{print $2}'
|tr
-d
"addr:"
`
do
# 把ip转换成整数
ip_int
=
`
echo
$i
|awk
-F
.
'{printf "%d\n", ($1*(2^24))+($2*(2^16))+($3*(2^8))+$4}'
`
ip_int
=
$(
ip_value
$i
)
if
[
$((
$ip_int
&
$mask
))
-eq
$prefix
]
then
ip
=
$i
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help