Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
0176-Use-a-portable-method-for-removing-a-line-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0176-Use-a-portable-method-for-removing-a-line-from-a-fil.patch of Package erlang
From 0a09e6198c1f7df2eaf7fecb5737947635c49890 Mon Sep 17 00:00:00 2001 From: Michal Palka <michal.palka@hiq.se> Date: Thu, 15 Apr 2021 16:26:41 +0200 Subject: [PATCH 2/3] Use a portable method for removing a line from a file --- lib/ssl/test/make_certs.erl | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/ssl/test/make_certs.erl b/lib/ssl/test/make_certs.erl index 0efa776be2..ea655df782 100644 --- a/lib/ssl/test/make_certs.erl +++ b/lib/ssl/test/make_certs.erl @@ -184,17 +184,25 @@ revoke(Root, CA, User, C) -> gencrl(Root, CA, C). %% Remove the certificate's entry from the database. The OCSP responder -%% will consider the certificate unknown. +%% will consider the certificate to be unknown. remove_entry(Root, CA, User, C) -> Db = filename:join([Root, CA, "index.txt"]), - Cmd = ["grep", " -v" - " \"/CN=", User ,"/\" ", Db, - " > ", Db, "~new"], - cmd(Cmd, []), - Cmd2 = ["mv ", Db, "~new ", Db], - cmd(Cmd2, []), + remove_line_with_pattern(Db, "/CN=" ++ User ++ "/"), gencrl(Root, CA, C). +remove_line_with_pattern(File, Pattern) -> + {ok, Bin} = file:read_file(File), + AllLines = string:lexemes(Bin, [$\n,"\r\n"]), + MaybeRemove = fun(Line, Acc) -> + case string:find(Line, Pattern) of + nomatch -> [Line|Acc]; + _ -> Acc + end + end, + RevLines = lists:foldl(MaybeRemove, [], AllLines), + Lines = lists:join("\n", lists:reverse(RevLines)), + ok = file:write_file(File, iolist_to_binary(Lines)). + gencrl(Root, CA, C) -> %% By default, the CRL is valid for a week from now. gencrl(Root, CA, C, 24*7). -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor