Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
1e7c91c6
Commit
1e7c91c6
authored
Apr 07, 2016
by
Ad Schellevis
Committed by
Franco Fichtner
Apr 12, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(legacy) whitespace rc.update_alias_url_data
(cherry picked from commit
bfe5a992
)
parent
c484637e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
80 deletions
+84
-80
rc.update_alias_url_data
src/etc/rc.update_alias_url_data
+84
-80
No files found.
src/etc/rc.update_alias_url_data
View file @
1e7c91c6
#!/usr/local/bin/php
#!/usr/local/bin/php
<?php
<?php
/*
/*
Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
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
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
POSSIBILITY OF SUCH DAMAGE.
*/
*/
require_once
(
"config.inc"
);
require_once
(
"config.inc"
);
...
@@ -33,72 +32,77 @@ require_once("pfsense-utils.inc");
...
@@ -33,72 +32,77 @@ require_once("pfsense-utils.inc");
function
update_alias_url_data
()
function
update_alias_url_data
()
{
{
global
$config
;
global
$config
;
$updated
=
false
;
/* item is a url type */
$updated
=
false
;
$lockkey
=
lock
(
'aliasurl'
);
/* item is a url type */
if
(
isset
(
$config
[
'aliases'
][
'alias'
])
&&
is_array
(
$config
[
'aliases'
][
'alias'
]))
{
$lockkey
=
lock
(
'aliasurl'
);
foreach
(
$config
[
'aliases'
][
'alias'
]
as
$x
=>
$alias
)
{
if
(
isset
(
$config
[
'aliases'
][
'alias'
])
&&
is_array
(
$config
[
'aliases'
][
'alias'
]))
{
if
(
empty
(
$alias
[
'aliasurl'
]))
foreach
(
$config
[
'aliases'
][
'alias'
]
as
$x
=>
$alias
)
{
continue
;
if
(
empty
(
$alias
[
'aliasurl'
]))
{
continue
;
}
$address
=
""
;
$address
=
""
;
$isfirst
=
0
;
$isfirst
=
0
;
foreach
(
$alias
[
'aliasurl'
]
as
$alias_url
)
{
foreach
(
$alias
[
'aliasurl'
]
as
$alias_url
)
{
/* fetch down and add in */
/* fetch down and add in */
$temp_filename
=
tempnam
(
'/tmp/'
,
'alias_import'
);
$temp_filename
=
tempnam
(
'/tmp/'
,
'alias_import'
);
unlink
(
$temp_filename
);
unlink
(
$temp_filename
);
$verify_ssl
=
isset
(
$config
[
'system'
][
'checkaliasesurlcert'
]);
$verify_ssl
=
isset
(
$config
[
'system'
][
'checkaliasesurlcert'
]);
mkdir
(
$temp_filename
);
mkdir
(
$temp_filename
);
download_file
(
$alias_url
,
$temp_filename
.
"/aliases"
,
$verify_ssl
);
download_file
(
$alias_url
,
$temp_filename
.
"/aliases"
,
$verify_ssl
);
/* if the item is tar gzipped then extract */
/* if the item is tar gzipped then extract */
if
(
stripos
(
$alias_url
,
'.tgz'
))
{
if
(
stripos
(
$alias_url
,
'.tgz'
))
{
if
(
!
process_alias_tgz
(
$temp_filename
))
if
(
!
process_alias_tgz
(
$temp_filename
))
{
continue
;
continue
;
}
else
if
(
stripos
(
$alias_url
,
'.zip'
))
{
}
if
(
!
process_alias_unzip
(
$temp_filename
))
}
elseif
(
stripos
(
$alias_url
,
'.zip'
))
{
continue
;
if
(
!
process_alias_unzip
(
$temp_filename
))
{
}
continue
;
if
(
file_exists
(
"
{
$temp_filename
}
/aliases"
))
{
}
$fd
=
@
fopen
(
"
{
$temp_filename
}
/aliases"
,
'r'
);
}
if
(
!
$fd
)
{
if
(
file_exists
(
"
{
$temp_filename
}
/aliases"
))
{
log_error
(
sprintf
(
gettext
(
'Could not process aliases from alias: %s'
),
$alias_url
));
$fd
=
@
fopen
(
"
{
$temp_filename
}
/aliases"
,
'r'
);
continue
;
if
(
!
$fd
)
{
}
log_error
(
sprintf
(
gettext
(
'Could not process aliases from alias: %s'
),
$alias_url
));
/* NOTE: fgetss() is not a typo RTFM before being smart */
continue
;
while
((
$fc
=
fgetss
(
$fd
))
!==
FALSE
)
{
}
$tmp
=
trim
(
$fc
,
"
\t\n\r
"
);
/* NOTE: fgetss() is not a typo RTFM before being smart */
if
(
empty
(
$tmp
))
while
((
$fc
=
fgetss
(
$fd
))
!==
FALSE
)
{
continue
;
$tmp
=
trim
(
$fc
,
"
\t\n\r
"
);
$tmp_str
=
strstr
(
$tmp
,
'#'
,
true
);
if
(
empty
(
$tmp
))
{
if
(
!
empty
(
$tmp_str
))
continue
;
$tmp
=
$tmp_str
;
}
if
(
$isfirst
==
1
)
$tmp_str
=
strstr
(
$tmp
,
'#'
,
true
);
$address
.=
' '
;
if
(
!
empty
(
$tmp_str
))
{
$address
.=
$tmp
;
$tmp
=
$tmp_str
;
$isfirst
=
1
;
}
}
if
(
$isfirst
==
1
)
{
fclose
(
$fd
);
$address
.=
' '
;
mwexec
(
"/bin/rm -rf
{
$temp_filename
}
"
);
}
}
$address
.=
$tmp
;
}
$isfirst
=
1
;
if
(
!
empty
(
$address
))
{
}
$config
[
'aliases'
][
'alias'
][
$x
][
'address'
]
=
$address
;
fclose
(
$fd
);
$updated
=
true
;
mwexec
(
"/bin/rm -rf
{
$temp_filename
}
"
);
}
}
}
}
}
if
(
!
empty
(
$address
))
{
unlock
(
$lockkey
);
$config
[
'aliases'
][
'alias'
][
$x
][
'address'
]
=
$address
;
$updated
=
true
;
}
}
}
unlock
(
$lockkey
);
/* Report status to callers as well */
/* Report status to callers as well */
return
$updated
;
return
$updated
;
}
}
if
(
update_alias_url_data
())
{
if
(
update_alias_url_data
())
{
write_config
();
write_config
();
configd_run
(
"filter reload"
);
configd_run
(
"filter reload"
);
}
}
Write
Preview
Markdown
is supported
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