Merge branch 'freebsd/current/main' into hardened/current/master

This commit is contained in:
HardenedBSD Sync Services 2024-10-25 12:01:49 -06:00
commit 85ab09b094
No known key found for this signature in database
20 changed files with 150 additions and 125 deletions

View File

@ -3226,6 +3226,7 @@ lib/libc__L: lib/libsys__L
lib/libgcc_s__L: lib/libc__L
lib/libgcc_s__L: lib/libc_nonshared__L
lib/libcxxrt__L: lib/libgcc_s__L
lib/libcrypt__L: lib/libmd__L
_prebuild_libs= ${_kerberos5_lib_libasn1} \
${_kerberos5_lib_libhdb} \

View File

@ -9,5 +9,7 @@
#include <expected>
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 23
const char* bad_expected_access<void>::what() const noexcept { return "bad access to std::expected"; }
#endif
_LIBCPP_END_NAMESPACE_STD

View File

@ -129,6 +129,7 @@ SUBDIR_DEPEND_libc++:= libcxxrt
SUBDIR_DEPEND_libc= libsys libcompiler_rt libssp_nonshared
SUBDIR_DEPEND_libcam= libsbuf
SUBDIR_DEPEND_libcasper= libnv
SUBDIR_DEPEND_libcrypt= libmd
SUBDIR_DEPEND_libdevstat= libkvm
SUBDIR_DEPEND_libdpv= libfigpar ncurses libutil
SUBDIR_DEPEND_libedit= ncurses

View File

@ -104,7 +104,15 @@ CFLAGS+= -ffunction-sections
CFLAGS+= -fno-semantic-interposition
CFLAGS+= -fvisibility-inlines-hidden
CFLAGS+= -fvisibility=hidden
.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} < 130000
# NOTE: gcc 12 cannot correctly compile all libc++'s C++23 code. To temporarily
# support gcc 12, compile libc++ in C++20 mode, but this will leave out any
# C++23 features.
CXXSTD?= c++20
.else
CXXSTD?= c++23
.endif
LIBADD+= cxxrt

View File

@ -10,17 +10,15 @@ PACKAGE= runtime
SHLIB_MAJOR= 5
LIB= crypt
.PATH: ${SRCTOP}/sys/kern ${SRCTOP}/sys/crypto/sha2
SRCS= crypt.c misc.c \
crypt-md5.c md5c.c \
crypt-nthash.c md4c.c \
crypt-sha256.c sha256c.c \
crypt-sha512.c sha512c.c
crypt-md5.c \
crypt-nthash.c \
crypt-sha256.c \
crypt-sha512.c
MAN= crypt.3
MLINKS= crypt.3 crypt_get_format.3 crypt.3 crypt_r.3 \
crypt.3 crypt_set_format.3
CFLAGS+= -I${SRCTOP}/lib/libmd \
-I${SRCTOP}/sys/crypto/sha2
CFLAGS+= -I${SRCTOP}/lib/libmd
# Pull in the strong crypto, if it is present.
.if exists(${SRCTOP}/secure/lib/libcrypt) && ${MK_CRYPT} != "no"
@ -29,17 +27,6 @@ SRCS+= crypt-des.c crypt-blowfish.c blowfish.c
CFLAGS+= -I${.CURDIR} -DHAS_DES -DHAS_BLOWFISH
.endif
.for sym in MD4Init MD4Final MD4Update MD4Pad \
MD5Init MD5Final MD5Update MD5Pad \
SHA224_Init SHA224_Final SHA224_Update \
SHA256_Init SHA256_Final SHA256_Update \
SHA512_224_Init SHA512_224_Final SHA512_224_Update \
SHA512_256_Init SHA512_256_Final SHA512_256_Update \
SHA384_Init SHA384_Final SHA384_Update \
SHA512_Init SHA512_Final SHA512_Update
CFLAGS+= -D${sym}=__${sym}
.endfor
WARNS?= 2
PRECIOUSLIB=
@ -47,4 +34,22 @@ PRECIOUSLIB=
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
LIBADD+= md
SHLIB_LDSCRIPT= libcrypt.ldscript
STATIC_LDSCRIPT= libcrypt.aldscript
CLEANFILES+= libcrypt.ald
libcrypt.ald: ${.CURDIR}/${STATIC_LDSCRIPT}
sed -e 's,@@LIB@@,${LIB},g' \
-e 's,@@STATICLIB_SUFFIX@@,${_STATICLIB_SUFFIX},g' \
${.ALLSRC} > ${.TARGET}
all: ${STATIC_LDSCRIPT} libcrypt.ald
install-libcrypt.a: libcrypt.ald
${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dev} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
${_INSTALLFLAGS} libcrypt.ald ${DESTDIR}${_LIBDIR}/lib${LIB}.a
realinstall: install-libcrypt.a
.include <bsd.lib.mk>

View File

@ -32,6 +32,7 @@
#include <md5.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include "crypt.h"
@ -84,7 +85,7 @@ crypt_md5(const char *pw, const char *salt, char *buffer)
(u_int)(pl > MD5_SIZE ? MD5_SIZE : pl));
/* Don't leave anything around in vm they could use. */
memset(final, 0, sizeof(final));
explicit_bzero(final, sizeof(final));
/* Then something really weird... */
for (i = strlen(pw); i; i >>= 1)
@ -140,7 +141,7 @@ crypt_md5(const char *pw, const char *salt, char *buffer)
*buffer = '\0';
/* Don't leave anything around in vm they could use. */
memset(final, 0, sizeof(final));
explicit_bzero(final, sizeof(final));
return (0);
}

View File

@ -41,6 +41,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "crypt.h"
@ -234,9 +235,9 @@ crypt_sha256(const char *key, const char *salt, char *buffer)
* the SHA256 implementation as well. */
SHA256_Init(&ctx);
SHA256_Final(alt_result, &ctx);
memset(temp_result, '\0', sizeof(temp_result));
memset(p_bytes, '\0', key_len);
memset(s_bytes, '\0', salt_len);
explicit_bzero(temp_result, sizeof(temp_result));
explicit_bzero(p_bytes, key_len);
explicit_bzero(s_bytes, salt_len);
return (0);
}

View File

@ -41,6 +41,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "crypt.h"
@ -246,9 +247,9 @@ crypt_sha512(const char *key, const char *salt, char *buffer)
* the SHA512 implementation as well. */
SHA512_Init(&ctx);
SHA512_Final(alt_result, &ctx);
memset(temp_result, '\0', sizeof(temp_result));
memset(p_bytes, '\0', key_len);
memset(s_bytes, '\0', salt_len);
explicit_bzero(temp_result, sizeof(temp_result));
explicit_bzero(p_bytes, key_len);
explicit_bzero(s_bytes, salt_len);
return (0);
}

View File

@ -0,0 +1 @@
INPUT(-l@@LIB@@@@STATICLIB_SUFFIX@@ -lmd)

View File

@ -0,0 +1 @@
INPUT(@@SHLIB@@ AS_NEEDED(-lmd))

View File

@ -81,7 +81,7 @@ static GElf_Addr ef_symaddr(elf_file_t ef, GElf_Size symidx);
static int ef_lookup_set(elf_file_t ef, const char *name,
GElf_Addr *startp, GElf_Addr *stopp, long *countp);
static int ef_lookup_symbol(elf_file_t ef, const char *name,
GElf_Sym **sym);
GElf_Sym **sym, bool see_local);
static struct elf_file_ops ef_file_ops = {
.close = ef_close,
@ -126,7 +126,7 @@ ef_get_offset(elf_file_t ef, GElf_Addr addr)
* next two functions copied from link_elf.c
*/
static int
ef_lookup_symbol(elf_file_t ef, const char *name, GElf_Sym **sym)
ef_lookup_symbol(elf_file_t ef, const char *name, GElf_Sym **sym, bool see_local)
{
unsigned long hash, symnum;
GElf_Sym *symp;
@ -156,8 +156,11 @@ ef_lookup_symbol(elf_file_t ef, const char *name, GElf_Sym **sym)
if (symp->st_shndx != SHN_UNDEF ||
(symp->st_value != 0 &&
GELF_ST_TYPE(symp->st_info) == STT_FUNC)) {
*sym = symp;
return (0);
if (see_local ||
GELF_ST_BIND(symp->st_info) != STB_LOCAL) {
*sym = symp;
return (0);
}
} else
return (ENOENT);
}
@ -183,14 +186,14 @@ ef_lookup_set(elf_file_t ef, const char *name, GElf_Addr *startp,
/* get address of first entry */
snprintf(setsym, len, "%s%s", "__start_set_", name);
error = ef_lookup_symbol(ef, setsym, &sym);
error = ef_lookup_symbol(ef, setsym, &sym, true);
if (error != 0)
goto out;
*startp = sym->st_value;
/* get address of last entry */
snprintf(setsym, len, "%s%s", "__stop_set_", name);
error = ef_lookup_symbol(ef, setsym, &sym);
error = ef_lookup_symbol(ef, setsym, &sym, true);
if (error != 0)
goto out;
*stopp = sym->st_value;

View File

@ -101,7 +101,7 @@ static GElf_Addr ef_obj_symaddr(elf_file_t ef, GElf_Size symidx);
static int ef_obj_lookup_set(elf_file_t ef, const char *name,
GElf_Addr *startp, GElf_Addr *stopp, long *countp);
static int ef_obj_lookup_symbol(elf_file_t ef, const char *name,
GElf_Sym **sym);
GElf_Sym **sym, bool see_local);
static struct elf_file_ops ef_obj_file_ops = {
.close = ef_obj_close,
@ -129,7 +129,8 @@ ef_obj_get_offset(elf_file_t ef, GElf_Addr addr)
}
static int
ef_obj_lookup_symbol(elf_file_t ef, const char *name, GElf_Sym **sym)
ef_obj_lookup_symbol(elf_file_t ef, const char *name, GElf_Sym **sym,
bool see_local)
{
GElf_Sym *symp;
const char *strp;
@ -138,8 +139,11 @@ ef_obj_lookup_symbol(elf_file_t ef, const char *name, GElf_Sym **sym)
for (i = 0, symp = ef->ddbsymtab; i < ef->ddbsymcnt; i++, symp++) {
strp = ef->ddbstrtab + symp->st_name;
if (symp->st_shndx != SHN_UNDEF && strcmp(name, strp) == 0) {
*sym = symp;
return (0);
if (see_local ||
GELF_ST_BIND(symp->st_info) != STB_LOCAL) {
*sym = symp;
return (0);
}
}
}
return (ENOENT);

View File

@ -688,7 +688,8 @@ elf_reloc(struct elf_file *efile, const void *reldata, Elf_Type reltype,
}
int
elf_lookup_symbol(struct elf_file *efile, const char *name, GElf_Sym **sym)
elf_lookup_symbol(struct elf_file *efile, const char *name, GElf_Sym **sym,
bool see_local)
{
return (EF_LOOKUP_SYMBOL(efile, name, sym));
return (EF_LOOKUP_SYMBOL(efile, name, sym, see_local));
}

View File

@ -48,8 +48,8 @@
(ef)->ef_ops->symaddr((ef)->ef_ef, symidx)
#define EF_LOOKUP_SET(ef, name, startp, stopp, countp) \
(ef)->ef_ops->lookup_set((ef)->ef_ef, name, startp, stopp, countp)
#define EF_LOOKUP_SYMBOL(ef, name, sym) \
(ef)->ef_ops->lookup_symbol((ef)->ef_ef, name, sym)
#define EF_LOOKUP_SYMBOL(ef, name, sym, see_local) \
(ef)->ef_ops->lookup_symbol((ef)->ef_ef, name, sym, see_local)
/* XXX, should have a different name. */
typedef struct ef_file *elf_file_t;
@ -69,7 +69,8 @@ struct elf_file_ops {
GElf_Addr (*symaddr)(elf_file_t ef, GElf_Size symidx);
int (*lookup_set)(elf_file_t ef, const char *name, GElf_Addr *startp,
GElf_Addr *stopp, long *countp);
int (*lookup_symbol)(elf_file_t ef, const char *name, GElf_Sym **sym);
int (*lookup_symbol)(elf_file_t ef, const char *name, GElf_Sym **sym,
bool see_local);
};
typedef int (elf_reloc_t)(struct elf_file *ef, const void *reldata,
@ -317,11 +318,9 @@ int elf_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
* Find the symbol with the specified symbol name 'name' within the given
* 'efile'. 0 is returned when such a symbol is found, otherwise ENOENT is
* returned.
*
* XXX: This only return the first symbol being found when traversing symtab.
*/
int elf_lookup_symbol(struct elf_file *efile, const char *name,
GElf_Sym **sym);
GElf_Sym **sym, bool see_local);
__END_DECLS

View File

@ -46,8 +46,8 @@ EC2-SMALL_DESC= Amazon EC2 small image
GCE_FORMAT= raw
GCE_FSLIST?= ufs zfs
GCE_DESC= Google Compute Engine image
ORACLE_FORMAT= qcow2
ORACLE_FSLIST?= ufs
ORACLE_FORMAT= raw
ORACLE_FSLIST?= ufs zfs
ORACLE_DESC= Oracle Cloud Infrastructure image
OPENSTACK_FORMAT=qcow2
OPENSTACK_FSLIST?= ufs

View File

@ -330,6 +330,7 @@ _DP_cap_grp= nv
_DP_cap_pwd= nv
_DP_cap_sysctl= nv
_DP_cap_syslog= nv
_DP_crypt= md
.if ${MK_OFED} != "no"
_DP_pcap= ibverbs mlx5
.endif

View File

@ -1686,11 +1686,10 @@ zio_do_crypt_data(boolean_t encrypt, zio_crypt_key_t *key,
freebsd_crypt_session_t *tmpl = NULL;
uint8_t *authbuf = NULL;
memset(&puio_s, 0, sizeof (puio_s));
memset(&cuio_s, 0, sizeof (cuio_s));
zfs_uio_init(&puio, &puio_s);
zfs_uio_init(&cuio, &cuio_s);
memset(GET_UIO_STRUCT(&puio), 0, sizeof (struct uio));
memset(GET_UIO_STRUCT(&cuio), 0, sizeof (struct uio));
#ifdef FCRYPTO_DEBUG
printf("%s(%s, %p, %p, %d, %p, %p, %u, %s, %p, %p, %p)\n",

View File

@ -455,7 +455,6 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index,
struct sctp_ifalist *hash_addr_head;
struct sctp_ifnlist *hash_ifn_head;
uint32_t hash_of_addr;
int new_ifn_af = 0;
#ifdef SCTP_DEBUG
SCTPDBG(SCTP_DEBUG_PCB4, "vrf_id 0x%x: adding address: ", vrf_id);
@ -519,59 +518,63 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index,
LIST_INSERT_HEAD(hash_ifn_head, sctp_ifnp, next_bucket);
LIST_INSERT_HEAD(&vrf->ifnlist, sctp_ifnp, next_ifn);
atomic_add_int(&SCTP_BASE_INFO(ipi_count_ifns), 1);
new_ifn_af = 1;
}
sctp_ifap = sctp_find_ifa_by_addr(addr, vrf->vrf_id, SCTP_ADDR_LOCKED);
if (sctp_ifap) {
/* Hmm, it already exists? */
if ((sctp_ifap->ifn_p) &&
(sctp_ifap->ifn_p->ifn_index == ifn_index)) {
SCTPDBG(SCTP_DEBUG_PCB4, "Using existing ifn %s (0x%x) for ifa %p\n",
sctp_ifap->ifn_p->ifn_name, ifn_index,
(void *)sctp_ifap);
if (new_ifn_af) {
/* Remove the created one that we don't want */
sctp_delete_ifn(sctp_ifnp);
}
if (sctp_ifap->localifa_flags & SCTP_BEING_DELETED) {
/* easy to solve, just switch back to active */
SCTPDBG(SCTP_DEBUG_PCB4, "Clearing deleted ifa flag\n");
sctp_ifap->localifa_flags = SCTP_ADDR_VALID;
sctp_ifap->ifn_p = sctp_ifnp;
atomic_add_int(&sctp_ifap->ifn_p->refcount, 1);
}
exit_stage_left:
SCTP_IPI_ADDR_WUNLOCK();
if (new_sctp_ifnp != NULL) {
SCTP_FREE(new_sctp_ifnp, SCTP_M_IFN);
}
SCTP_FREE(new_sctp_ifap, SCTP_M_IFA);
return (sctp_ifap);
} else {
if (sctp_ifap->ifn_p) {
if (sctp_ifap != NULL) {
/* The address being added is already or still known. */
if (sctp_ifap->ifn_p != NULL) {
if (sctp_ifap->ifn_p->ifn_index == ifn_index) {
SCTPDBG(SCTP_DEBUG_PCB4,
"Using existing ifn %s (0x%x) for ifa %p\n",
sctp_ifap->ifn_p->ifn_name, ifn_index,
(void *)sctp_ifap);
if (new_sctp_ifnp == NULL) {
/* Remove the created one not used. */
sctp_delete_ifn(sctp_ifnp);
}
if (sctp_ifap->localifa_flags & SCTP_BEING_DELETED) {
/* Switch back to active. */
SCTPDBG(SCTP_DEBUG_PCB4,
"Clearing deleted ifa flag\n");
sctp_ifap->localifa_flags = SCTP_ADDR_VALID;
sctp_ifap->ifn_p = sctp_ifnp;
atomic_add_int(&sctp_ifap->ifn_p->refcount, 1);
}
} else {
/*
* The last IFN gets the address, remove the
* old one
*/
SCTPDBG(SCTP_DEBUG_PCB4, "Moving ifa %p from %s (0x%x) to %s (0x%x)\n",
(void *)sctp_ifap, sctp_ifap->ifn_p->ifn_name,
SCTPDBG(SCTP_DEBUG_PCB4,
"Moving ifa %p from %s (0x%x) to %s (0x%x)\n",
(void *)sctp_ifap,
sctp_ifap->ifn_p->ifn_name,
sctp_ifap->ifn_p->ifn_index, if_name,
ifn_index);
/* remove the address from the old ifn */
sctp_remove_ifa_from_ifn(sctp_ifap);
/* move the address over to the new ifn */
sctp_add_ifa_to_ifn(sctp_ifnp, sctp_ifap);
goto exit_stage_left;
} else {
/* repair ifnp which was NULL ? */
sctp_ifap->localifa_flags = SCTP_ADDR_VALID;
SCTPDBG(SCTP_DEBUG_PCB4, "Repairing ifn %p for ifa %p\n",
(void *)sctp_ifnp, (void *)sctp_ifap);
sctp_add_ifa_to_ifn(sctp_ifnp, sctp_ifap);
}
goto exit_stage_left;
} else {
/* Repair ifn_p, which was NULL... */
sctp_ifap->localifa_flags = SCTP_ADDR_VALID;
SCTPDBG(SCTP_DEBUG_PCB4,
"Repairing ifn %p for ifa %p\n",
(void *)sctp_ifnp, (void *)sctp_ifap);
sctp_add_ifa_to_ifn(sctp_ifnp, sctp_ifap);
}
SCTP_IPI_ADDR_WUNLOCK();
if (new_sctp_ifnp != NULL) {
SCTP_FREE(new_sctp_ifnp, SCTP_M_IFN);
}
SCTP_FREE(new_sctp_ifap, SCTP_M_IFA);
return (sctp_ifap);
}
KASSERT(sctp_ifnp != NULL,
("sctp_add_addr_to_vrf: sctp_ifnp == NULL"));
KASSERT(sctp_ifap == NULL,
("sctp_add_addr_to_vrf: sctp_ifap (%p) != NULL", sctp_ifap));
sctp_ifap = new_sctp_ifap;
memset(sctp_ifap, 0, sizeof(struct sctp_ifa));
sctp_ifap->ifn_p = sctp_ifnp;
@ -597,8 +600,8 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index,
sctp_ifap->src_is_priv = 1;
}
sctp_ifnp->num_v4++;
if (new_ifn_af)
new_ifn_af = AF_INET;
if (new_sctp_ifnp == NULL)
sctp_ifnp->registered_af = AF_INET;
break;
}
#endif
@ -617,13 +620,12 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index,
sctp_ifap->src_is_priv = 1;
}
sctp_ifnp->num_v6++;
if (new_ifn_af)
new_ifn_af = AF_INET6;
if (new_sctp_ifnp == NULL)
sctp_ifnp->registered_af = AF_INET6;
break;
}
#endif
default:
new_ifn_af = 0;
break;
}
hash_of_addr = sctp_get_ifa_hash_val(&sctp_ifap->address.sa);
@ -639,9 +641,6 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index,
sctp_ifnp->ifa_count++;
vrf->total_ifa_count++;
atomic_add_int(&SCTP_BASE_INFO(ipi_count_ifas), 1);
if (new_ifn_af) {
sctp_ifnp->registered_af = new_ifn_af;
}
SCTP_IPI_ADDR_WUNLOCK();
if (new_sctp_ifnp != NULL) {
SCTP_FREE(new_sctp_ifnp, SCTP_M_IFN);

View File

@ -147,8 +147,6 @@ name##_PCTRIE_INSERT_LOOKUP_GE(struct pctrie *ptree, struct type *ptr, \
*found_out = NULL; \
return (ENOMEM); \
} \
if (neighbor == parentp) \
neighbor = parent; \
pctrie_insert_node(parentp, parent, val); \
} \
found = pctrie_subtree_lookup_gt(neighbor, *val); \
@ -178,8 +176,6 @@ name##_PCTRIE_INSERT_LOOKUP_LE(struct pctrie *ptree, struct type *ptr, \
*found_out = NULL; \
return (ENOMEM); \
} \
if (neighbor == parentp) \
neighbor = parent; \
pctrie_insert_node(parentp, parent, val); \
} \
found = pctrie_subtree_lookup_lt(neighbor, *val); \

View File

@ -328,10 +328,10 @@ diff2reviewers()
jq '.response.data[0].attachments.reviewers.reviewers[] | select(.status == "accepted").reviewerPHID')
if [ -n "$userids" ]; then
echo '{
"constraints": {"phids": ['"$(echo -n "$userids" | tr '[:space:]' ',')"']}
"constraints": {"phids": ['"$(printf "%s" "$userids" | tr '[:space:]' ',')"']}
}' |
arc_call_conduit -- user.search |
jq -r '.response.data[].fields.username'
arc_call_conduit -- user.search |
jq -r '.response.data[].fields.username'
fi
}
@ -444,7 +444,7 @@ gitarc__list()
for commit in $commits; do
chash=$(git show -s --format='%C(auto)%h' "$commit")
echo -n "${chash} "
printf "%s" "${chash} "
diff=$(log2diff "$commit")
if [ -n "$diff" ]; then
@ -461,7 +461,7 @@ gitarc__list()
if [ -z "$diff" ]; then
echo "No Review : $title"
elif [ "$(echo "$diff" | wc -l)" -ne 1 ]; then
echo -n "Ambiguous Reviews: "
printf "%s" "Ambiguous Reviews: "
echo "$diff" | grep -E -o 'D[1-9][0-9]*:' | tr -d ':' \
| paste -sd ',' - | sed 's/,/, /g'
else
@ -548,32 +548,32 @@ patch_commit()
diff=$1
reviewid=$(diff2phid "$diff")
# Get the author phid for this patch
review_data=$(echo '{
"constraints": {"phids": ["'"$reviewid"'"]}
}' |
arc_call_conduit -- differential.revision.search)
authorid=$(echo "$review_data" | jq -r '.response.data[].fields.authorPHID' )
review_data=$(mktemp)
echo '{"constraints": {"phids": ["'"$reviewid"'"]}}' | \
arc_call_conduit -- differential.revision.search > "$review_data"
authorid=$(jq -r '.response.data[].fields.authorPHID' "$review_data")
# Get metadata about the user that submitted this patch
user_data=$(echo '{
"constraints": {"phids": ["'"$authorid"'"]}
}' |
arc call-conduit -- user.search | grep -v ^Warning: |
jq -r '.response.data[].fields')
user_addr=$(echo "$user_data" | jq -r '.username')
user_name=$(echo "$user_data" | jq -r '.realName')
user_data=$(mktemp)
echo '{"constraints": {"phids": ["'"$authorid"'"]}}' | \
arc_call_conduit -- user.search | \
jq -r '.response.data[].fields' > "$user_data"
user_addr=$(jq -r '.username' "$user_data")
user_name=$(jq -r '.realName' "$user_data")
rm "$user_data"
# Dig the data out of querydiffs api endpoint, although it's deprecated,
# since it's one of the few places we can get email addresses. It's unclear
# if we can expect multiple difference ones of these. Some records don't
# have this data, so we remove all the 'null's. We sort the results and
# remove duplicates 'just to be sure' since we've not seen multiple
# records that match.
diff_data=$(echo '{
"revisionIDs": [ '"${diff#D}"' ]
}' | arc_call_conduit -- differential.querydiffs |
jq -r '.response | flatten | .[]')
author_addr=$(echo "$diff_data" | jq -r ".authorEmail?" | sort -u)
author_name=$(echo "$diff_data" | jq -r ".authorName?" | sort -u)
diff_data=$(mktemp)
echo '{"revisionIDs": [ '"${diff#D}"' ]}' | \
arc_call_conduit -- differential.querydiffs |
jq -r '.response | flatten | .[]' > "$diff_data"
author_addr=$(jq -r ".authorEmail?" "$diff_data" | sort -u)
author_name=$(jq -r ".authorName?" "$diff_data" | sort -u)
author=$(find_author "$user_addr" "$user_name" "$author_addr" "$author_name")
rm "$diff_data"
# If we had to guess, and the user didn't want to guess, abort
if [ "${author}" = "ABORT" ]; then
@ -582,10 +582,11 @@ patch_commit()
fi
tmp=$(mktemp)
echo "$review_data" | jq -r '.response.data[].fields.title' > $tmp
jq -r '.response.data[].fields.title' "$review_data" > $tmp
echo >> $tmp
echo "$review_data" | jq -r '.response.data[].fields.summary' >> $tmp
jq -r '.response.data[].fields.summary' "$review_data" >> $tmp
echo >> $tmp
rm "$review_data"
# XXX this leaves an extra newline in some cases.
reviewers=$(diff2reviewers "$diff" | sed '/^$/d' | paste -sd ',' - | sed 's/,/, /g')
if [ -n "$reviewers" ]; then