Skip to content

Commit 24e41c6

Browse files
committed
resolvconf: Allow -p to list private entries without -a
1 parent cc8206d commit 24e41c6

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

resolvconf.8.in

+11-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2323
.\" SUCH DAMAGE.
2424
.\"
25-
.Dd March 24, 2025
25+
.Dd April 21, 2025
2626
.Dt RESOLVCONF 8
2727
.Os
2828
.Sh NAME
@@ -46,7 +46,7 @@
4646
.Fl d Ar interface Ns Op Ar .protocol
4747
.Nm
4848
.Op Fl x
49-
.Fl iLl Ar pattern
49+
.Fl iLlp Ar pattern
5050
.Nm
5151
.Fl u
5252
.Nm
@@ -149,10 +149,14 @@ Only really useful for deleting interfaces.
149149
Set the metric of the interface when adding it, default of 0.
150150
Lower metrics take precedence.
151151
This affects the default order of interfaces when listed.
152-
.It Fl p
152+
.It Fl p Op Ar pattern
153153
Marks the interface
154154
.Pa resolv.conf
155-
as private.
155+
as private if the
156+
.Fl a
157+
command is given, otherwise private interfaces matching
158+
.Ar pattern
159+
are listed.
156160
.It Fl x
157161
Mark the interface
158162
.Pa resolv.conf
@@ -162,13 +166,13 @@ as exclusive when adding, otherwise only use the latest exclusive interface.
162166
.Nm
163167
has some more commands for general usage:-
164168
.Bl -tag -width pattern_opt
165-
.It Fl i Ar pattern
169+
.It Fl i Op Ar pattern
166170
List the interfaces and protocols, optionally matching
167171
.Ar pattern ,
168172
we have
169173
.Pa resolv.conf
170174
files for.
171-
.It Fl L Ar pattern
175+
.It Fl L Op Ar pattern
172176
List the
173177
.Pa resolv.conf
174178
files we have,
@@ -179,7 +183,7 @@ If
179183
.Ar pattern
180184
is specified then we list the files for the interfaces and protocols
181185
that match it.
182-
.It Fl l Ar pattern
186+
.It Fl l Op Ar pattern
183187
List the
184188
.Pa resolv.conf
185189
files we have.

resolvconf.in

+25-1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ resolv_strip()
167167

168168
private_iface()
169169
{
170+
iface="$1"
171+
170172
# Allow expansion
171173
cd "$IFACEDIR"
172174

@@ -650,6 +652,19 @@ list_resolv()
650652
return $retval
651653
}
652654

655+
list_private()
656+
{
657+
IFACES=
658+
for i in $(list_resolv -i $@ 2>/dev/null); do
659+
if private_iface "$i"; then
660+
IFACES="${IFACES}${IFACES:+ }$i"
661+
fi
662+
done
663+
if [ -n "$IFACES" ]; then
664+
echo "$IFACES"
665+
fi
666+
}
667+
653668
list_remove()
654669
{
655670
[ -z "$2" ] && return 0
@@ -828,6 +843,10 @@ done
828843
shift $(($OPTIND - 1))
829844
args="$iface${iface:+ }$*"
830845

846+
if [ -z "$cmd" ] && [ "$IF_PRIVATE" = 1 ]; then
847+
cmd=p
848+
fi
849+
831850
# -I inits the state dir
832851
if [ "$cmd" = I ]; then
833852
if [ -d "$VARDIR" ]; then
@@ -850,7 +869,12 @@ fi
850869
# -L is the same as -l, but post-processed from our config
851870
if [ "$cmd" = L ]; then
852871
list_resolv "-$cmd" "$args" | replace
853-
exit $?2
872+
exit $?
873+
fi
874+
875+
if [ "$cmd" = p ]; then
876+
list_private "$args"
877+
exit $?
854878
fi
855879

856880
# Restart a service or echo the command to restart a service

0 commit comments

Comments
 (0)